On 7 Feb 2013, at 11:03, MacArthur, Ian (Selex ES, UK) wrote:
>
>> I have an app that, in its menu structure, has some FL_MENU_TOGGLE
>> entries that show a check mark... Now, depending on various happenings
>> within the code, these check marks may be set or cleared
>> programmatically at runtime, using e.g. item->set(); and item->clear();
>>
>> All well and good - except on OSX where I am using Fl_Sys_Menu_Bar,
>> where the changes to the state of the toggles are never shown by the
>> menus...
>
>
> I took a brief look at this, and it does seem as if the
> Fl_Sys_Menu_Bar on OSX does not get "updated" to reflect the
> changes caused by the Fl_Menu_Item::set(),clear() and set_only()
> methods, in its current form.
>
> Not sure how to make that work (it is beyond my OSX-fu skills)
> but I guess it might be possible to "sledgehammer" it by triggering
> a call to convertToMenuBar(...) which would tear down and then
> rebuild the entire Fl_Sys_Menu_Bar.
>
> Sounds a bit heavy-handed, but should work and mean that the
> state is reported correctly...
>
> Anyway, that looks like something that I can do by deriving my
> own class from Fl_Sys_Menu_Bar and adding a few new methods
> to test it, so I'll maybe take a stab at that later.
> (No OSX machines in this office, so can't test now!)
OK - outcomes...
Didn't need to do anything clever in the end; just a bit of a nasty hack
instead!
Turns out that calling Fl_Sys_Menu_Bar::replace(); will cause OSX to tear down
and rebuild the menu structure, and thus make it reflect the current state of
the check marks and so forth.
So, just pick a menu entry, then rename it to itself, and...
Something like this:
// Apple / OSX specific hack to force the menu to be rebuilt
// NOT needed on win32/linux...
int idx = mb1->find_index("File/item 1");
mb1->replace(idx, "item 1");
// end of menu rebuild hack...
Seems to work just fine. As a workaround.
A proper fix would be nice though!
Cheers,
--
Ian
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk