On 11/5/22 01:48, Manolo wrote:On 11/5/22 01:11, Mo_Al_ wrote:
Hello
Is there a way to detect whether Fl_Menu_Button is popped-up prior to calling clear on it?
While the menu is pulled down, Fl::grab() returns the menu window and it returns NULL when the menu window is closed.Thus, you can modify your timeout_cb function as follows
void timeout_cb(void *) {
puts("running timeout");
if (!Fl::grab()) {
m->clear();
m->add("Jan|Feb|Mar");
}
Fl::repeat_timeout(1.0, timeout_cb, 0);
}
If there are other grabbing windows around in your app, you would also have to make sure Fl::grab() returns another window.
* Should FLTK provide is_posted() or is_popup() or some such method to Fl_Menu_ and friends?
* Add warnings in docs for all the Fl_Menu_ 'clear()' methods/suggest how to avoid?
* Perhaps clear() methods should automatically schedule/defer the work until the menu finishes posting?
+1 : I don't find it extremely useful, but it is a protective measure and takes only a few lines of code.
I can see where applications showing realtime status of asynchronous events could run into this easily.
* Should FLTK provide is_posted() or is_popup() or some such method to Fl_Menu_ and friends?
* Add warnings in docs for all the Fl_Menu_ 'clear()' methods/suggest how to avoid?
* Perhaps clear() methods should automatically schedule/defer the work until the menu finishes posting?
On Saturday, 5 November 2022 at 09:36:23 UTC er...@seriss.com wrote:
I can see where applications showing realtime status of asynchronous events could run into this easily.
Though in (I do not know how long) I don't think I have ever actually hit this, so it might not be that common a use case?
* Add warnings in docs for all the Fl_Menu_ 'clear()' methods/suggest how to avoid?
* Perhaps clear() methods should automatically schedule/defer the work until the menu finishes posting?Though that might get a bit more involved?
Agreed it might be involved, and if we can't implement it
cleanly,
then we really must warn about the situation in the docs,
then.
I think we already have a warning about the app keeping
possibly
stale pointers to items.
As tough as it is for FLTK to implement, I think it'd be even
tougher for the
application software to do it.