[Solved] Need two events to always react
Posted: Wed Feb 15, 2017 11:05 am
SOLVED - See next post.
I may have asked this before but I couldn't find it.
My app has a hotkey event and button event that BOTH need to be triggered at any time, no matter what the user is doing. My event loop currently looks like the below, but as you can see, as soon as something interrupts the loop (the ColorRequester) then the hotkey can't respond anymore.
I tried BindEvent(#WM_HOTKEY,@HotKeyEvent()) but #WM_HOTKEY isn't valid.
So what's the logical way to accomplish this goal? Thanks!
I also tried this, but if the MessageRequester is open then I can't click the ButtonGadget:
Even doing the HotKeyEvent() as a thread doesn't work:
So I'm fresh out of ideas. 

I may have asked this before but I couldn't find it.

My app has a hotkey event and button event that BOTH need to be triggered at any time, no matter what the user is doing. My event loop currently looks like the below, but as you can see, as soon as something interrupts the loop (the ColorRequester) then the hotkey can't respond anymore.
I tried BindEvent(#WM_HOTKEY,@HotKeyEvent()) but #WM_HOTKEY isn't valid.

So what's the logical way to accomplish this goal? Thanks!
Code: Select all
Procedure HotKeyEvent()
MessageRequester("Dammit","Now you can't click the ButtonGadget! :)")
EndProcedure
hWnd=OpenWindow(0,200,200,220,40,"test",#PB_Window_SystemMenu)
RegisterHotKey_(hWnd,0,#MOD_CONTROL,#VK_BACK) ; Ctrl+Backspace.
ButtonGadget(0,10,10,200,20,"Click me and try to use the hotkey :(")
Repeat
Event=WaitWindowEvent()
If Event=#WM_HOTKEY
HotKeyEvent()
ElseIf Event=#PB_Event_Gadget
ColorRequester()
EndIf
Until Event=#PB_Event_CloseWindow
Code: Select all
Procedure HotKeyEvent()
MessageRequester("Dammit","Now you can't click the ButtonGadget! :)")
EndProcedure
Procedure MyCallback(hWnd,uMsg,WParam,LParam)
If uMsg=#WM_HOTKEY
HotKeyEvent()
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
hWnd=OpenWindow(0,200,200,220,40,"test",#PB_Window_SystemMenu)
RegisterHotKey_(hWnd,0,#MOD_CONTROL,#VK_BACK) ; Ctrl+Backspace.
ButtonGadget(0,10,10,200,20,"Click me and try to use the hotkey :(")
SetWindowCallback(@MyCallback())
Repeat
Event=WaitWindowEvent()
If Event=#PB_Event_Gadget
ColorRequester()
EndIf
Until Event=#PB_Event_CloseWindow
Code: Select all
Procedure HotKeyEvent(null)
MessageRequester("Dammit","Now you can't click the ButtonGadget! :)")
EndProcedure
Procedure MyCallback(hWnd,uMsg,WParam,LParam)
If uMsg=#WM_HOTKEY
CreateThread(@HotKeyEvent(),0)
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
hWnd=OpenWindow(0,200,200,220,40,"test",#PB_Window_SystemMenu)
RegisterHotKey_(hWnd,0,#MOD_CONTROL,#VK_BACK) ; Ctrl+Backspace.
ButtonGadget(0,10,10,200,20,"Click me and try to use the hotkey :(")
SetWindowCallback(@MyCallback())
Repeat
Event=WaitWindowEvent()
If Event=#PB_Event_Gadget
ColorRequester()
EndIf
Until Event=#PB_Event_CloseWindow
