Hold the button and an action

Hello
I am looking for a way to re-perform an operation by holding down a button. It is necessary that the operation is repeated many times until the end of the hold.

Is this doable? Is there any way to do this for this interface?

try(destroyDialog ::rlTest)catch()
rollout rlTest "" 
(
	dotnetcontrol btn_1 "Button" width:50 height:50 across:3 offset:[-13,-5]
	dotnetcontrol btn_2 "Button" width:50 height:50 align:#center offset:[1,-5]
	dotnetcontrol btn_3 "Button" width:50 height:50 offset:[5,-5]
 
	fn defColor r g b = (dotNetClass "System.Drawing.Color").FromArgb r g b
	fn defFont fName fSize = (dotNetObject "System.Drawing.Font" fName fSize ((dotNetClass "System.Drawing.FontStyle").bold))
	local C1 = defColor 100 100 100, C2 = defColor 255 255 255, C3 = defColor 150 20 20, C4 = defColor 150 180 90, Fnt = defFont "Century Gothic" 35
 
	on rlTest open do
	(
		btn_1.font = Fnt
		btn_2.font = Fnt
		btn_3.font = Fnt
 
		btn_1.text = "\x2B78"
		btn_2.text = "\x2B76"
		btn_3.text = "\x2B71"
 
		btn_1.foreColor = C2; btn_1.backColor = C4
		btn_2.foreColor = C2; btn_2.backColor = C4
		btn_3.foreColor = C2; btn_3.backColor = C4
 
		btn_1.TextAlign = btn_1.TextAlign.MiddleCenter ; btn_1.FlatStyle = btn_1.FlatStyle.Flat
		btn_2.TextAlign = btn_2.TextAlign.MiddleCenter ; btn_2.FlatStyle = btn_2.FlatStyle.Flat
		btn_3.TextAlign = btn_3.TextAlign.MiddleCenter ; btn_3.FlatStyle = btn_3.FlatStyle.Flat
	)
 
	on btn_1 MouseUp arg do(if selection.count == 1 do(undo on(move $ [25, 0, 0])))
 
	on btn_2 MouseUp arg do(if selection.count == 1 do(undo on(move $ [0, 25, 0])))
 
	on btn_3 MouseUp arg do(if selection.count == 1 do(undo on(move $ [0, 0, 25])))
)
createDialog rlTest 150 50

Any help appreciated.

Comments

Comment viewing options

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

 

try destroyDialog ::rlTest catch()
rollout rlTest "" 
(
	dotNetControl btn_1 "Button" width:50 height:50 across:3 offset:[-13,-5]
	dotNetControl btn_2 "Button" width:50 height:50 align:#center offset:[1,-5]
	dotNetControl btn_3 "Button" width:50 height:50 offset:[5,-5]
	timer clock interval:100 active:off
 
	fn defColor r g b = (dotNetClass "System.Drawing.Color").FromArgb r g b
	fn defFont fName fSize = (dotNetObject "System.Drawing.Font" fName fSize ((dotNetClass "System.Drawing.FontStyle").bold))
	local C1 = defColor 100 100 100, C2 = defColor 255 255 255, C3 = defColor 150 20 20, C4 = defColor 150 180 90, Fnt = defFont "Century Gothic" 35
	local offset = [0, 0, 0]
 
	fn startMoving offset =
	(
		rlTest.offset = offset
		theHold.SuperBegin()
		clock.active = on
	)
 
	fn stopMoving =
	(
		clock.active = off
		theHold.SuperAccept() 
	)
 
	on clock tick do with undo on
		move selection offset
 
	on rlTest open do
	(
		btn_1.font = Fnt
		btn_2.font = Fnt
		btn_3.font = Fnt
 
		btn_1.text = "\x2B78"
		btn_2.text = "\x2B76"
		btn_3.text = "\x2B71"
 
		btn_1.foreColor = C2; btn_1.backColor = C4
		btn_2.foreColor = C2; btn_2.backColor = C4
		btn_3.foreColor = C2; btn_3.backColor = C4
 
		btn_1.TextAlign = btn_1.TextAlign.MiddleCenter ; btn_1.FlatStyle = btn_1.FlatStyle.Flat
		btn_2.TextAlign = btn_2.TextAlign.MiddleCenter ; btn_2.FlatStyle = btn_2.FlatStyle.Flat
		btn_3.TextAlign = btn_3.TextAlign.MiddleCenter ; btn_3.FlatStyle = btn_3.FlatStyle.Flat
	)
 
	on btn_1 MouseDown arg do if selection.count == 1 do startMoving [25, 0, 0]
	on btn_1 MouseUp arg do stopMoving()
 
	on btn_2 MouseDown arg do if selection.count == 1 do startMoving [0, 25, 0]
	on btn_2 MouseUp arg do stopMoving()
 
	on btn_3 MouseDown arg do if selection.count == 1 do startMoving [0, 0, 25]
	on btn_3 MouseUp arg do stopMoving()
)
createDialog rlTest 150 50
Igryl9l's picture

Uii!

Amazing! Thank you very much for your help!

Comment viewing options

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