Notifications
Clear all

[Closed] DestroyDialog by time / mouse position

hey there!

I’m trying to destroy a rollout after a little amount of time. The point is to display a messagebox-like window where you wouldn’t need to close it.

I tried with the timeStamp() function but this is not a good choice at all, because it litteraly freezes max.

try (destroyDialog test) catch ()

fn waitForIt =
(
local timeRef = (timeStamp()/1000) + 2

do
(
if timeRef > (timeStamp()/1000) do
destroyDialog test

) while 1

)
rollout test “” width:150 height:150
(
on test open do
waitForIt()

)
createDialog test

Then I thought of the mouse position: if the mouse position changed the rollout is destroyed. But there’s still a problem. I can have the position by using dotnet:

cursor = dotnetclass “System.Windows.Forms.Cursor”
p = cursor.Position

but no clue on how to check it multiple times in a rollout…
Do you have an idea?
Thank you

2 Replies
try(destroydialog message_time_escape_or_mouse_move) catch()
rollout message_time_escape_or_mouse_move "" width:200 height:60
(
	label message_lb "K I L L   M E  ! ! !" align:#center offset:[0,20]
	timer kill_tm interval:100 active:off
	
	
	local mouse_pos = undefined
	
	on kill_tm tick do
	(
		--if (distance mouse.pos mouse_pos > 100) \ -- move cursor move than 100 pixels out
			if keyboard.escpressed \ -- press ESCAPE
			or kill_tm.ticks >= 100 do -- wait 10 sec
		(
			destroydialog message_time_escape_or_mouse_move 
		)
	)
	on message_time_escape_or_mouse_move open do
	(
		mouse_pos = mouse.pos 
		kill_tm.active = on
	)

)
createdialog message_time_escape_or_mouse_move style:#(#style_border)

I wasn’t aware of the tick event! Thanks a lot, it works like a charm!