Add a final value to the "enum FL_Event" list?

13 views
Skip to first unread message

Brian Larsen

unread,
Jul 3, 2024, 7:41:40 AM (3 days ago) Jul 3
to fltk.general
Would it make sense to add a final value to the "enum FL_Event" list
in Enumerations.H? This would allow code to more easily define custom
events; even if no one ever did that it seems like a reasonable safe
change.

The new item could either be the last value in the list or the first
available value. Currently the last event is "FL_ZOOM_EVENT = 27" so
the new item I'm suggesting would be one of the following (maybe with
a name you like better)

FL_LAST_EVENT_NUM = 27
  -- or --
FL_FIRST_USER_EVENT_NUM = 28

Brian Larsen

unread,
Jul 3, 2024, 8:30:46 AM (3 days ago) Jul 3
to fltk.general
Sorry, was I supposed to put this in GitHub discussions instead?

Albrecht Schlosser

unread,
Jul 3, 2024, 9:07:16 AM (3 days ago) Jul 3
to fltkg...@googlegroups.com
On 7/3/24 14:30 Brian Larsen wrote:
Sorry, was I supposed to put this in GitHub discussions instead?

No, not necessarily, but you could have done it. It's still experimental. The "Development" category would have been fine for this.

And to answer your question: I don't think that it makes much sense to add such an enum value, especially not for adding user events. We don't support user code sending FLTK events, and if we did, then this would need some work so users could send events with proper context etc..

That said, 'FL_LAST_EVENT[_NUM]' might be an option but I'm not sure what it would be good for. Maybe someone else has an idea...

Brian Larsen

unread,
Jul 3, 2024, 9:35:28 AM (3 days ago) Jul 3
to fltk.general
I was just playing around and made a "MY_APP_TIMER = 28", which I manually sent to my main 
window handle() function whenever 25ms had elapsed, e.g. mainWindow->handle(MY_APP_TIMER).

I'm not using Fl::run(), I'm using a while(1) loop that calls Fl:wait() and also calls a couple of functions 
in my app, so the above call to handle() can happen in this loop without causing a reentrant call.

I guess calling this an "event" is not correct, but it's a value that doesn't collide with real FLTK events 
which handle() can process. Obviously it's best if handle() always returns 1 for custom "event" values 
so FLTK never tries to deal with them.

Anyway, it would be nice to have the FL_LAST_EVENT_[NUM] symbol for weird experiments like this.

Reply all
Reply to author
Forward
0 new messages