WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Mouse and Viz.Input (https://forum.worldviz.com/showthread.php?t=1042)

bjgold 04-09-2007 11:51 AM

Mouse and Viz.Input
 
Code:

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:
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

izard 3.0 the mouse event does not seem to be fired when I'm on a slider
 
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:
Code:

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:
Code:

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!!
 
Thank you, it worked!


All times are GMT -7. The time now is 11:25 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC