Page 1 of 1
Bug in PostEvent()?
Posted: Sat Mar 01, 2025 7:22 am
by tua
Code: Select all
EnableExplicit
Enumeration Events #PB_Event_FirstCustomValue
#Event_Custom1
EndEnumeration
Define EventID
Procedure ButtonClicked()
Debug PostEvent(#Event_Custom1)
EndProcedure
If OpenWindow(0, 0, 0, 300, 100, "Bug? demo", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, 50, 50, 60, 30, "Click me")
BindGadgetEvent(1, @ButtonClicked(), #PB_EventType_LeftClick)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #Event_Custom1
Debug "Custom1 event detected"
EndSelect
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Every post attempt returns 0, yet quite a number of posts succeed according to the trap in the event loop - any ideas what's not working as designed here (Windows, PB 6.20)?
Re: Bug in PostEvent()?
Posted: Sat Mar 01, 2025 9:17 am
by Little John
No bug in PostEvent().
Never use
WaitWindowEvent() more than once in an event loop!
Code: Select all
Until EventID = #PB_Event_CloseWindow
works as expected.
Re: Bug in PostEvent()?
Posted: Sat Mar 01, 2025 4:50 pm
by tua
While what you point out is certainly true (I just hastily pasted a demo together - my bad), it has nothing to do with the issue.
PostEvent succeeds, as can be seen by the events being trapped, yet it returns 0 = failure, when according to the documentation
Returns a non-zero value if the event was sent without error, zero otherwise.
Re: Bug in PostEvent()?
Posted: Sat Mar 01, 2025 5:02 pm
by Little John
tua wrote: Sat Mar 01, 2025 4:50 pm
PostEvent succeeds, as can be seen by the events being trapped, yet it returns 0 = failure
Yes, that's a contradiction to the documentation.
Re: Bug in PostEvent()?
Posted: Sat Mar 01, 2025 5:58 pm
by mk-soft
Is an bug under Windows. Under macOS and Linux it returns a 1 (True)
But I've never analysed it so far because it always works (if you don't do anything wrong)
Re: Bug in PostEvent()?
Posted: Sat Mar 01, 2025 6:15 pm
by Little John
mk-soft wrote: Sat Mar 01, 2025 5:58 pm
But I've never analysed it so far because it always works (if you don't do anything wrong)
Yep.

Re: Bug in PostEvent()?
Posted: Sat Mar 01, 2025 6:16 pm
by tua
Thanks for confirming - will file a bug report (if one does not already exist).