WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 04-11-2011, 06:41 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use a delayed timer to detect when the mouse stops moving after a certain amount of time. The following script shows how to do this:
Code:
import viz
viz.go()

MOUSE_STILL_EVENT = viz.getEventID('MouseStillEvent')

class MouseStillHandler(viz.EventClass):
	def __init__(self,delay=0.25):
		viz.EventClass.__init__(self)
		self.still_delay = delay

		self.callback(viz.TIMER_EVENT,self._onTimer)
		self.callback(viz.MOUSE_MOVE_EVENT,self._onMouseMove)

	def _onTimer(self,num):
		viz.sendEvent(MOUSE_STILL_EVENT,viz.Event(delay=self.still_delay))
		self.killtimer(0)

	def _onMouseMove(self,e):
		self.killtimer(0)
		self.starttimer(0,self.still_delay)


handler = MouseStillHandler()

def onMouseStill(e):
	print 'Mouse still'

viz.callback(MOUSE_STILL_EVENT,onMouseStill)
Reply With Quote
 

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 08:50 PM.


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