If a MessageRequester() is poped up in front of your main window, all events from menus and gadgets seems blocked, except for some CanvasGadget Events. If you move your mouse cursor over the blocked main window with a CanvasGadget on it, the events
#PB_EventType_MouseLeave
#PB_EventType_MouseEnter
#PB_EventType_MouseMove
are still being triggered. I don't know if this is a bug or intended behavior. But I want no events to happen in the background when a requester is open. Does anyone have any ideas? I use BindGadgetEvent(#GID_Canvas...) for my GagedEvents.
Turn off Canvas Events during a MessageRequester() is open
Re: Turn off Canvas Events during a MessageRequester() is open
What OS are you using? I don't get any events when a message requester is open on Windows.
You could try unbinding the events before opening a message requester and then binding them after it. Does this work? I haven't tested it on macOS.
You could try unbinding the events before opening a message requester and then binding them after it. Does this work? I haven't tested it on macOS.
Code: Select all
Procedure OnCanvasEvents()
Select EventType()
Case #PB_EventType_MouseLeave
Debug "leave"
Case #PB_EventType_MouseEnter
Debug "enter"
Case #PB_EventType_MouseMove
Debug "move"
EndSelect
EndProcedure
Procedure OnButtonEvent()
UnbindEvent(#PB_Event_Gadget, @OnCanvasEvents(), 0, 0, #PB_All)
MessageRequester("", "...", #PB_MessageRequester_Ok)
BindGadgetEvent(0, @OnCanvasEvents(), #PB_All)
EndProcedure
If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 10, 40, 200, 170)
ButtonGadget(1, 10, 10, 90, 25, "Click")
BindGadgetEvent(0, @OnCanvasEvents(), #PB_All)
BindGadgetEvent(1, @OnButtonEvent())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIfRe: Turn off Canvas Events during a MessageRequester() is open
Thanks.It seems that could be the way...
I wonder why the #PB_EventType_LeftButtonDown for example is blocked with Requester, but not the #PB_EventType_MouseMove
I wonder why the #PB_EventType_LeftButtonDown for example is blocked with Requester, but not the #PB_EventType_MouseMove
Re: Turn off Canvas Events during a MessageRequester() is open
It's in use by the modal dialog, whereas the mouse position isn't especially significant and hasn't been overriden by a dialog specific function. It's an emergent behaviour of a hierarchical object structure, rather than something intentional.Lebostein wrote: Sat Nov 08, 2025 8:51 pm I wonder why the #PB_EventType_LeftButtonDown for example is blocked with Requester, but not the #PB_EventType_MouseMove
This gets cumbersome in a big application and is prone to introducing bugs if you forget to unbind/rebind something along the way. I usually define a flag variable something like "EventsActive" and have something like this at the top of the event procedures:wombats wrote: Sat Nov 08, 2025 7:42 pm You could try unbinding the events before opening a message requester and then binding them after it.
Code: Select all
Procedure SomeBoundEvent()
If EventsActive = #False
ProcedureReturn
Endif
EndProcedureRe: Turn off Canvas Events during a MessageRequester() is open
I found another solution! With DisableWindow()! I always thought a requester did exactly that (the manual says "Opens a blocking requester"), but apparently a requester does not have such strict blocking conditions on the underlying window. In my opinion, this is still a bug/inconsistency. At least in the manual.
Code: Select all
Procedure OnCanvasEvents()
Select EventType()
Case #PB_EventType_MouseLeave
Debug "leave"
Case #PB_EventType_MouseEnter
Debug "enter"
Case #PB_EventType_MouseMove
Debug "move"
EndSelect
EndProcedure
Procedure OnButtonEvent()
DisableWindow(0, #True)
MessageRequester("", "...", #PB_MessageRequester_Ok)
DisableWindow(0, #False)
EndProcedure
If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 10, 40, 200, 170)
ButtonGadget(1, 10, 10, 90, 25, "Click")
BindGadgetEvent(0, @OnCanvasEvents(), #PB_All)
BindGadgetEvent(1, @OnButtonEvent())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIfRe: Turn off Canvas Events during a MessageRequester() is open
In fact, this is the correct solution. Use the DisableWindow( ) function. As for the events, they should have worked until I enabled DisableWindow( )
Re: Turn off Canvas Events during a MessageRequester() is open
That's how I would have solved it.
But with a macro. So you don't have to search the whole program
Update
But with a macro. So you don't have to search the whole program
Update
Code: Select all
;- Fix MessageRequester lock events
Procedure MyMessageRequester(Title.s, Text.s, Flags=0, ParentID=0)
Protected r1, ActWindow
ActWindow = GetActiveWindow()
DisableWindow(ActWindow, #True)
r1 = MessageRequester(Title, Text, Flags, ParentID)
DisableWindow(ActWindow, #False)
ProcedureReturn r1
EndProcedure
Macro MessageRequester(Title, Text, Flags=0, ParentID=0)
MyMessageRequester(Title, Text, Flags, ParentID)
EndMacro
; ****
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Turn off Canvas Events during a MessageRequester() is open
Yes, this happens a lot.
I am on the side of "roll your own requester" window at startup and make hidden until activated.
Then you get full control of the size, position, fonts and context.
I am on the side of "roll your own requester" window at startup and make hidden until activated.
Then you get full control of the size, position, fonts and context.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


