WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-09-2007, 11:51 AM
bjgold bjgold is offline
Member
 
Join Date: Jul 2006
Posts: 19
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!
Reply With Quote
  #2  
Old 04-10-2007, 09:21 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
  #3  
Old 04-19-2007, 04:59 AM
johannes2 johannes2 is offline
Member
 
Join Date: Apr 2007
Posts: 7
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
Reply With Quote
  #4  
Old 04-19-2007, 09:30 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
  #5  
Old 04-20-2007, 01:21 PM
johannes2 johannes2 is offline
Member
 
Join Date: Apr 2007
Posts: 7
Thank you!!

Thank you, it worked!
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:23 AM.


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