@@ -51,30 +51,43 @@ static SDL_EventType_MenuExt EVENT_START = (SDL_EventType_MenuExt)0;
5151
5252void PrintMenuItems (SDL_Renderer * renderer , SDL_MenuItem * menu_item , int indent , int * total_index )
5353{
54+ SDL_MenuItem * app_menu = NULL ;
55+ Sint64 item_count = 0 ;
56+ Sint64 i = 0 ;
57+
5458 if (!menu_item ) {
5559 return ;
5660 }
5761
58- SDL_MenuItem * app_menu = SDL_GetMenuBarAppMenu (menu_item );
59- if (app_menu ) {
60- SDL_RenderDebugText (renderer , (float )(8 * indent * 2 ), (float )(* total_index * 8 ), " -> AppMenu" );
61- ++ (* total_index );
62- }
63-
6462 const char * label = SDL_GetMenuItemLabel (menu_item );
6563
6664 if (!label ) {
6765 label = "no label given" ;
6866 }
6967
7068 SDL_RenderDebugText (renderer , (float )(8 * indent * 2 ), (float )(* total_index * 8 ), label );
71-
7269 ++ (* total_index );
70+
71+
72+ if (SDL_GetMenuItemType (menu_item ) == SDL_MENUITEM_MENUBAR ) {
73+ app_menu = SDL_GetMenuBarAppMenu (menu_item );
74+
75+ if (app_menu ) {
76+ SDL_RenderDebugText (renderer , (float )(8 * (indent + 1 ) * 2 ), (float )(* total_index * 8 ), " -> AppMenu" );
77+ ++ (* total_index );
78+
79+ item_count = SDL_GetMenuChildItems (app_menu );
80+
81+ for (i = 0 ; i < item_count ; ++ i ) {
82+ PrintMenuItems (renderer , SDL_GetMenuChildItem (app_menu , (size_t )i ), indent + 2 , total_index );
83+ }
84+ }
85+ }
7386
74- size_t item_count = SDL_GetMenuChildItems (menu_item );
87+ item_count = SDL_GetMenuChildItems (menu_item );
7588
76- for (size_t i = 0 ; i < item_count ; ++ i ) {
77- PrintMenuItems (renderer , SDL_GetMenuChildItem (menu_item , i ), indent + 1 , total_index );
89+ for (i = 0 ; i < item_count ; ++ i ) {
90+ PrintMenuItems (renderer , SDL_GetMenuChildItem (menu_item , ( size_t ) i ), indent + 1 , total_index );
7891 }
7992}
8093
@@ -114,10 +127,10 @@ void CreateMenuBar_1()
114127
115128 SDL_MenuItem * app_menu = SDL_GetMenuBarAppMenu (menu_bar_1 );
116129 if (app_menu ) {
117- SDL_assert (!SDL_CreateMenuItem (menu_bar_1 , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT ));
118- SDL_CreateMenuItem (app_menu , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
130+ SDL_assert (!SDL_CreateMenuItem (menu_bar_1 , "Exit 1 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT ));
131+ SDL_CreateMenuItem (app_menu , "Exit 1 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
119132 } else {
120- SDL_CreateMenuItem (menu_bar_1 , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
133+ SDL_CreateMenuItem (menu_bar_1 , "Exit 1 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
121134 }
122135 }
123136
@@ -161,10 +174,10 @@ void CreateMenuBar_2()
161174
162175 SDL_MenuItem * app_menu = SDL_GetMenuBarAppMenu (menu_bar_2 );
163176 if (app_menu ) {
164- SDL_assert (!SDL_CreateMenuItem (menu_bar_2 , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT ));
165- SDL_CreateMenuItem (app_menu , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
177+ SDL_assert (!SDL_CreateMenuItem (menu_bar_2 , "Exit 2 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT ));
178+ SDL_CreateMenuItem (app_menu , "Exit 2 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
166179 } else {
167- SDL_CreateMenuItem (menu_bar_2 , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
180+ SDL_CreateMenuItem (menu_bar_2 , "Exit 2 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
168181 }
169182 }
170183
0 commit comments