Skip to content

Commit

Permalink
Moved and cleaned up SampleMouseCallback.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dalefugier committed Apr 25, 2019
1 parent a35cc01 commit 673079e
Showing 1 changed file with 15 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,59 +1,46 @@
# inspired by Dale Fugier's post here: https://discourse.mcneel.com/t/button-mouse-event-again/74625/14

################################################################################
# SampleMouseCallback.py
# Copyright (c) 2019 Robert McNeel & Associates.
# See License.md in the root of this repository for details.
################################################################################
import scriptcontext as sc
import Rhino

######################
### EVENT HANDLERS ###
######################
# Demonstrates how to use RhinoCommon's MouseCallback class
class MouseCallbackClass(Rhino.UI.MouseCallback):
""""""

def OnMouseDown(self, e):
print "OnMouseDown",e.Button

"""
def OnEndMouseDown(self,e):
print "OnEndMouseDown", e.Button
"""
""""""

def OnMouseUp(self,e):
print "OnMouseUp",e.Button

"""
def OnEndMouseUp(self,e):
print "OnEndMouseUp",e.Button
"""
""""""

def OnMouseDoubleClick(self,e):
print "OnMouseDoubleClick",e.Button

"""
def OnMouseMove(self,e):
print "OnMouseMove"
"""
"""

def OnEndMouseMove(self,e):
print "OnEndMouseMove"
"""
""""""

def OnMouseEnter(self,e):
print "OnMouseEnter", e.View.MainViewport.Name

""""""
def OnMouseLeave(self,e):
print "OnMouseLeave", e.View.MainViewport.Name

""""""
def OnMouseHover(self,e):
print "OnMouseHover"


##############################
### EVENT HELPER FUNCTIONS ###
##############################

# The 'main' function
def mouse_event_helper_func():
#Event trigger helper function
if sc.sticky.has_key('SampleMouseCallback'):
callback = sc.sticky['SampleMouseCallback']
if callback:
Expand All @@ -64,10 +51,10 @@ def mouse_event_helper_func():
callback = MouseCallbackClass()
callback.Enabled = True
sc.sticky['SampleMouseCallback'] = callback
#Rhino.RhinoApp.WriteLine("Click somewhere...")
print "Listening for mouse events..."



# Check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__ == "__main__":
mouse_event_helper_func()

0 comments on commit 673079e

Please sign in to comment.