[vtkusers] Identifying which button is pressed

dean.inglis at on.aibn.com dean.inglis at on.aibn.com
Thu Jul 10 09:33:41 EDT 2003


Paul,

Try adding this to VTK/Examples/GUI/Tcl/ImagePlaneWidget.tcl to get
the idea on how to listen in on the button events:


<snip>
# Set the interactor for the widgets
#

set iact [[$render_widget GetRenderWindow] GetInteractor]

set Cursoring 0
$iact AddObserver LeftButtonPressEvent CursorOn 1.0
$iact AddObserver LeftButtonReleaseEvent CursorOff 1.0
planeWidgetX AddObserver StartInteractionEvent CursorListener
planeWidgetX AddObserver EndInteractionEvent CursorListener


planeWidgetX SetPriority 0.9
planeWidgetX SetInteractor $iact
planeWidgetX On
planeWidgetY SetPriority 0.9
planeWidgetY SetInteractor $iact
planeWidgetY On
planeWidgetZ SetPriority 0.9
planeWidgetZ SetInteractor $iact
planeWidgetZ On

proc CursorOn {} {
  global Cursoring
  set Cursoring 1
}

proc CursorOff {} {
  global Cursoring
  set Cursoring 0
}

proc CursorListener {} {
  global Cursoring
  if { $Cursoring } {
     ren1 SetBackground  1 0.1 0.2
  } else {
     ren1 SetBackground  0.1 0.1 0.2
  }
  ren1 Render
}

# Create an initial interesting view
#
<snip>

regards,
Dean




More information about the vtkusers mailing list