PDA

View Full Version : Mouse and Viz.Input


bjgold
04-09-2007, 11:51 AM
viz.callback(viz.MOUSEDOWN_EVENT,onMouseDown) Does the above code work with input boxes? When a user clicks "ok" after entering text in the viz.input box, is there a way to have that mouse-click also run another event via the onMouseDown function? Or is that click "lost" to the viz.input box?

Thanks!

farshizzo
04-10-2007, 09:21 AM
The viz.MOUSEDOWN_EVENT is only triggered when the mouse is clicked on the main graphics window. If you want to monitor mouse clicks that occur outside the main graphics window, you can create a timer that checks the immediate state of the mouse buttons. Here is some sample code:lastState = 0
def CheckMouseDown():
global lastState
state = viz.mouse.getState(True)
if state & viz.MOUSEBUTTON_LEFT and not lastState & viz.MOUSEBUTTON_LEFT:
print 'mouse down'
lastState = state
vizact.ontimer(0,CheckMouseDown)

johannes2
04-19-2007, 04:59 AM
In Vizard 3.0 the mouse event does not seem to be fired when I'm on a slider.
I want that after changing the slider (MouseUp_event) some objects are reset.

Best,
Johannes

farshizzo
04-19-2007, 09:30 AM
Hi,

If you want to know when a slider is released, then handle the viz.BUTTON_EVENT and check for the slider object. Example:import viz
viz.go()

slider = viz.addSlider(pos=(0.5,0.1,0))

def onButton(obj,state):
if obj == slider and state == viz.UP:
print 'slider released'
viz.callback(viz.BUTTON_EVENT,onButton)If you still need to handle the mouse up event, then you need to register your callback with a lower priority number than the GUI priority. Example:import viz
viz.go()

slider = viz.addSlider(pos=(0.5,0.1,0))

def onMouseUp(button):
if button == viz.MOUSEBUTTON_LEFT:
print 'left button released'
viz.callback(viz.MOUSEUP_EVENT,onMouseUp,priority= viz.PRIORITY_GUI_HANDLER-1)

johannes2
04-20-2007, 01:21 PM
Thank you, it worked!