fix for windows hotkey problem

BlitzMax Forums/BlitzMax Module Tweaks/fix for windows hotkey problem

skidracer(Posted 2006) [#1]
This is an attempt to address the numerous bugreports regarding problems with hotkeys.

If you are a Windows BlitzMax 118 user that has been having problems can you please try a syncmods for the following fixes and report your findings below.



+ (BRL.MaxGui) Added optional owner window field to THotKey processing

+ (BRL.win32maxgui) Modified win32hwnd.cpp to call HotKeyEvent with foregroundwindow

+ (BRL.win32maxgui) Modified TWin32Gadget.SetHotKey method to set owner window





Difference(Posted 2006) [#2]
I mainly have the problem in the official IDE. Is there testbuild of that available?


Yan(Posted 2006) [#3]
Yay...I can now paste into the various IDE dialogues with CTRL+V. :o)


fredborg(Posted 2006) [#4]
Hi,

This problem: http://www.blitzbasic.com/Community/posts.php?topic=57470
is not fixed with this update.

Typing text in a TextField still generates menu events.

And setting a hotkey for a button doesn't seem to do anything? SetHotKeyEvent seems fine, but doesn't allow direct linking to a gadget as far as I can tell.
Local win:TGadget = CreateWindow("Hotkey test",100,100,200,100,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS)
Local abut:TGadget = CreateButton("'A' (SetHotKeyEvent)",5, 5,190,20,win)
Local bbut:TGadget = CreateButton("'B' (SetGadgetHotKey)",5,30,190,20,win)

SetHotKeyEvent(KEY_A,0)
SetGadgetHotKey(bbut,KEY_B,0)

While WaitEvent()

	Select EventSource()
		Case abut
			Notify "A Button clicked!"
		Case bbut
			Notify "B Button clicked!"
		Case win
			If EventID() = EVENT_WINDOWCLOSE
				End
			EndIf
	EndSelect

	If EventID() = EVENT_HOTKEYHIT
		Print "Hello"
	EndIf

Wend
[edit]I see now why SetGadgetHotKey doesn't work for a button, but really what's the point in having it, if it only applies to menus anyway?


Mark Tiffany(Posted 2006) [#5]
Thanks skid - confirmed fixed. The following bug reports can be moved to the bug bin:

http://www.blitzbasic.com/Community/posts.php?topic=55866
http://www.blitzbasic.com/Community/posts.php?topic=56724

The following two are identical to each other (double pasting on XP 64), anyone know if these are these fixed?

http://www.blitzbasic.com/Community/posts.php?topic=55699
http://www.blitzbasic.com/Community/posts.php?topic=56994

For anyone using the community IDE (and presumably the official BRL source too), just rebuild the source with the latest syncmods. I'll post a new EXE soon.


taxlerendiosk(Posted 2006) [#6]
Any chance of a new optional parameter for CreateMenu to make hotkeys application-wide rather than window-specific?


skidracer(Posted 2006) [#7]
fredborg, thanks for the code, hopefully this fixes the "hotkeys only work with menuitems" deficiancy

win32gui.mod/win32gui.bmx[503]

	Method SetHotKey(key,modifier)
		Local ev:TEvent
		Select class
		Case GADGET_MENUITEM
			bbSetMenuHotKey handle,key,modifier	'decorates name only
			ev=CreateEvent( EVENT_MENUACTION,Null,bbMenuTag(handle) )
			hotkey=SetHotKeyEvent(key,modifier,ev,findowner())
		Default
			ev=CreateEvent( EVENT_GADGETACTION,Self )
			hotkey=SetHotKeyEvent(key,modifier,ev,findowner())
		End Select
	End Method


denzil, I think it is most sensible that you still set the menu shortcut and then you set an additional hot key override afterwards to implement an application wide hotkey, given SetHotKey now works properly on win32.


fredborg(Posted 2006) [#8]
Yep, that fixes it for buttons etc. Top job!

Any word on the textfield vs. menu issue?