HotKeyEvent - Releasing the hotkey?

BlitzPlus Forums/BlitzPlus Programming/HotKeyEvent - Releasing the hotkey?

EOF(Posted 2003) [#1]
Is there a way to release an assigned hotkey?

HotKeyEvent 1,0,$401
...
HotKeyEvent 1,0,0

This does not appear to work.
I want to do this when I free up a GUI window which has hotkeys setup.

Look at this example. The F1 key no longer works.
Any ideas?


; HotKeyEvent - Release?

; GUI setup

win=CreateWindow("Window1",120,160,190,70,Desktop(),1)
button=CreateButton("Click me Or press F1",10,10,160,22,win)
HotKeyEvent 59,0,$401 ; <<- F1

; event handler

Repeat
	ev=WaitEvent()
	If ev=$803 Exit
	If ev=$401
		Notify "Button/F1 activated"
	EndIf
Forever

FlushEvents : HotKeyEvent 59,0,0
FreeGadget win : FlushKeys

; graphics setup 

Graphics 640,480,0,2
SetBuffer BackBuffer()

While Not KeyHit(1)
	If KeyHit(59) Or KeyHit(60) ; <<- F1 and F2
		ClsColor Rand(80),Rand(80),Rand(80)
	EndIf
	Cls
	Rect Rand(600),Rand(400),40,40,0
	Text 10,10,"Try pressing F1 to change background color"
	Text 10,30,"Or, use F2 which has no HotKey assigns ..."
	Flip
Wend

End




EWP(Posted 2003) [#2]
adding
id=WaitEvent(0)
If KeyHit(60) Or id=$401; <<- F1 and F2
to your final loop will make it work, but it appears that once you assign a hotkey you can't change it. In your example above pressing the hot key keeps generating the $401 event even though it has been changed.