Re: [AD] native menus

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Mon, Jun 20, 2011 at 6:07 PM, Evert Glebbeek <eglebbk@xxxxxxxxxx> wrote:
> When I did something with generating menus from code (not for Allegro, but could probably be adapted for this) I did figure out how to add menus and menu entries (fairly easy) but I didn't find out how you can remove a menu again. As far as I could tell you can't, or at least not easily.
>
How does the following seem with respect to OS X?

* al_get_supported_menu_types()
  1: application
  2: window (display)
  4: popup

* al_show_menu(ALLEGRO_MENU *menu, ALLEGRO_DISPLAY *display);

If window menus are NOT supported then the first call would always set
the application menu. Subsequent calls to setting display menus would
fail.

Perhaps passing NULL as the display could set the application menu
explicitly, but unless GTK supports both application (e.g., Unity) and
window menus, then I think making the distinction would only hinder
compatibility across platforms as Windows-only and OS X-only people
may not consider the other side.

* al_popup_menu(ALLEGRO_MENU *menu, ALLEGRO_DISPLAY  *display, int x,
int y, int flags);

Shows a context menu at the given location.

* al_hide_menu(ALLEGRO_MENU *menu);

Hides any menu of any type. If problematic, it wouldn't necessarily
need to be supported. (Although the OS specific implementation could
be to delete the menu item in question, and then re-add it if it is
later shown.)

* al_get_menu_event_source(ALLEGRO_MENU *menu)

All events get sent via that source, as opposed from a display source.

> I think you also can't change the order of menus (which is a problem, since we create the "Window" menu when the program starts, but it should be created last in order to show up at the right where it's supposed to).
>
I did a quick search on stackoverflow, and saw code like:

NSMenu* rootMenu = [NSApp mainMenu];
[rootMenu removeItemAtIndex:2];

Is that the type of menu Allegro is currently using? It seemed like it
could be updated programmatically from the various questions I looked
at.

--
Matthew Leverton




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/