gwText unregister when mouse move

Hi, I want the text I draw to be hidden after mouse move/pan/rotate or over time in viewport.
Here's my code:

(
	global GW_displayText
	unregisterRedrawViewsCallback GW_displayText
	fn GW_displayText = (
		rect = (box2 13 47 96 97)
		gw.Hrect rect red
		gw.hMarker (point3 20 207 0) #smallDiamond color:yellow
		gw.hText (point3 27 200 0) ("This is not a Standard material. Actual typ1e:") color:yellow
		gw.enlargeUpdateRect #whole 
		gw.updateScreen()
	)
	registerRedrawViewsCallback GW_displayText
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

...

You can use Timer.
In the example below, I set a timer to clean the screen after on 3 seconds

(
	global GW_displayText
	local clock = dotNetObject "Timer"
	clock.interval = 3000 -- 3000 milliseconds or 3 sec
	fn cleanScreen = (unregisterRedrawViewsCallback GW_displayText ; completeredraw() ; clock.stop())
	cleanScreen()
	fn GW_displayText = (
		rect = (box2 13 47 96 97)
		gw.Hrect rect red
		gw.hMarker (point3 20 207 0) #smallDiamond color:yellow
		gw.hText (point3 27 200 0) ("This is not a Standard material. Actual typ1e:") color:yellow
		gw.enlargeUpdateRect #whole 
		gw.updateScreen()
	)
	dotnet.addEventHandler clock "tick" cleanScreen
	registerRedrawViewsCallback GW_displayText
	clock.start() 
)

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.