|
Native Dialog Menu Problems |
Todd Cope
Member #998
November 2000
|
I came across some issues when working with the native dialog menu functions. The main issue is the menus simply don't work on OS X. I made a sample program that demonstrates the issue: 1#include <allegro5/allegro5.h>
2#include <allegro5/allegro_native_dialog.h>
3
4int main(int argc, char * argv[])
5{
6 ALLEGRO_DISPLAY * display;
7 ALLEGRO_MENU * test_menu;
8
9 if(!al_init())
10 {
11 return -1;
12 }
13 if(!al_init_native_dialog_addon())
14 {
15 return -1;
16 }
17 display = al_create_display(640, 480);
18 if(!display)
19 {
20 return -1;
21 }
22 test_menu = al_create_menu();
23 if(!test_menu)
24 {
25 return -1;
26 }
27 al_append_menu_item(test_menu, "Item 1", 1, 0, NULL, NULL);
28 al_append_menu_item(test_menu, "Item 2", 2, 0, NULL, NULL);
29 al_append_menu_item(test_menu, "Item 3", 3, 0, NULL, NULL);
30 al_append_menu_item(test_menu, "Item 4", 4, 0, NULL, NULL);
31 al_append_menu_item(test_menu, "Item 5", 5, 0, NULL, NULL);
32 al_append_menu_item(test_menu, "Item 6", 6, 0, NULL, NULL);
33 if(!al_set_display_menu(display, test_menu))
34 {
35 return -1;
36 }
37 al_rest(1.0);
38 return 0;
39}
The program crashes at the al_set_display_menu call. Creating a popup menu works somewhat, though it doesn't show child menus. Some work was done on it fairly recently (detailed here). I had hoped when I finally got back around to working on my programs that need the native menus, things would go smoothly. I have a working implementation which I made a couple of years ago (see this thread). I am using that for now so I can continue making my programs. The second issue is some confusion with the documentation. I have some menu items in my program that I need to be able to enable/disable by changing the flags for those particular items. When using al_set_menu_item_flags(), I thought I needed to provide an index instead of an ID because of the parameter name. So I used al_find_menu_item() to locate my menu item. When I set my flags, the wrong menu items had their flags changed. After some fiddling, I figured out that I could just pass the ID, but I should have been able to figure that out from looking at the documentation for the al_set_menu_item_flags() function. |
SiegeLord
Member #7,827
October 2006
|
This seems like a complicated topic, but I'll see if I can devote some time to it this week. EDIT: Make that the next week... . EDIT2: So I looked into this. I think the patch is better than nothing, but it's unfortunate that you need to do a lot of housekeeping for these menus. I'll play around with this some more and then merge it. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
|