OSX ios first version of application menubar support (#25863) * first version of app menubar support on ios, activate with wxUSE_MENUBAR = 1
... | ... | @@ -152,7 +152,9 @@ public: |
152 | 152 | virtual bool OSXOnShouldTerminate();
|
153 | 153 | // before application terminates
|
154 | 154 | virtual void OSXOnWillTerminate();
|
155 | - |
|
155 | +#if wxOSX_USE_IPHONE && wxUSE_MENUBAR
|
|
156 | + virtual void OSXOnBuildMenu(WX_NSObject menuBuilder);
|
|
157 | +#endif
|
|
156 | 158 | private:
|
157 | 159 | bool m_onInitResult;
|
158 | 160 | bool m_inited;
|
... | ... | @@ -151,6 +151,10 @@ public: |
151 | 151 | |
152 | 152 | wxMenu *OSXGetAppleMenu() const { return m_appleMenu; }
|
153 | 153 | |
154 | +#if wxOSX_USE_IPHONE
|
|
155 | + void OSXOnBuildMenu( WX_NSObject builder ) ;
|
|
156 | +#endif
|
|
157 | + |
|
154 | 158 | static void SetAutoWindowMenu( bool enable ) { s_macAutoWindowMenu = enable ; }
|
155 | 159 | static bool GetAutoWindowMenu() { return s_macAutoWindowMenu ; }
|
156 | 160 |
... | ... | @@ -220,6 +220,16 @@ bool wxApp::OSXOnShouldTerminate() |
220 | 220 | ProcessEvent(event);
|
221 | 221 | return !event.GetVeto();
|
222 | 222 | }
|
223 | + |
|
224 | +#endif
|
|
225 | + |
|
226 | +#if wxOSX_USE_IPHONE && wxUSE_MENUBAR
|
|
227 | + |
|
228 | +void wxApp::OSXOnBuildMenu(WX_NSObject builder)
|
|
229 | +{
|
|
230 | + wxMenuBar::MacGetInstalledMenuBar()->OSXOnBuildMenu(builder);
|
|
231 | +}
|
|
232 | + |
|
223 | 233 | #endif
|
224 | 234 | |
225 | 235 | #if wxDEBUG_LEVEL && wxOSX_USE_COCOA_OR_CARBON
|
... | ... | @@ -34,174 +34,24 @@ |
34 | 34 | // other standard headers
|
35 | 35 | // ----------------------
|
36 | 36 | #include <string.h>
|
37 | -/*
|
|
38 | -@implementation wxUIMenu
|
|
39 | 37 | |
40 | -- (id) initWithTitle:(NSString*) title
|
|
41 | -{
|
|
42 | - if ( self = [super initWithTitle:title] )
|
|
43 | - {
|
|
44 | - impl = nullptr;
|
|
45 | - }
|
|
46 | - return self;
|
|
47 | -}
|
|
48 | - |
|
49 | -- (void)setImplementation: (wxMenuImpl *) theImplementation
|
|
50 | -{
|
|
51 | - impl = theImplementation;
|
|
52 | -}
|
|
53 | - |
|
54 | -- (wxMenuImpl*) implementation
|
|
55 | -{
|
|
56 | - return impl;
|
|
57 | -}
|
|
58 | - |
|
59 | -@end
|
|
60 | -*/
|
|
61 | -// this is more compatible, as it is also called for command-key shortcuts
|
|
62 | -// and under 10.4, we are not getting a 'close' event however...
|
|
63 | -#define wxOSX_USE_NEEDSUPDATE_HOOK 1
|
|
64 | - |
|
65 | -@interface wxUIMenuController : NSObject // TODO wxIOS <UIMenuDelegate>
|
|
66 | -{
|
|
67 | -}
|
|
68 | - |
|
69 | -#if wxOSX_USE_NEEDSUPDATE_HOOK
|
|
70 | -- (void)menuNeedsUpdate:(UIMenu*)smenu;
|
|
71 | -#else
|
|
72 | -- (void)menuWillOpen:(UIMenu *)menu;
|
|
73 | -#endif
|
|
74 | -- (void)menuDidClose:(UIMenu *)menu;
|
|
75 | -- (void)menu:(UIMenu *)menu willHighlightItem:(UIMenuItem *)item;
|
|
76 | - |
|
77 | -@end
|
|
78 | - |
|
79 | -@implementation wxUIMenuController
|
|
80 | - |
|
81 | -- (id) init
|
|
82 | -{
|
|
83 | - self = [super init];
|
|
84 | - return self;
|
|
85 | -}
|
|
86 | - |
|
87 | -/*
|
|
88 | -#if wxOSX_USE_NEEDSUPDATE_HOOK
|
|
89 | -- (void)menuNeedsUpdate:(UIMenu*)smenu
|
|
90 | -{
|
|
91 | - wxUIMenu* menu = (wxUIMenu*) smenu;
|
|
92 | - wxMenuImpl* menuimpl = [menu implementation];
|
|
93 | - if ( menuimpl )
|
|
94 | - {
|
|
95 | - wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer();
|
|
96 | - if ( wxpeer )
|
|
97 | - wxpeer->HandleMenuOpened();
|
|
98 | - }
|
|
99 | -}
|
|
100 | -#else
|
|
101 | -- (void)menuWillOpen:(UIMenu *)smenu
|
|
102 | -{
|
|
103 | - wxUIMenu* menu = (wxUIMenu*) smenu;
|
|
104 | - wxMenuImpl* menuimpl = [menu implementation];
|
|
105 | - if ( menuimpl )
|
|
106 | - {
|
|
107 | - wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer();
|
|
108 | - if ( wxpeer )
|
|
109 | - wxpeer->HandleMenuOpened();
|
|
110 | - }
|
|
111 | -}
|
|
112 | -#endif
|
|
113 | - |
|
114 | -- (void)menuDidClose:(UIMenu *)smenu
|
|
115 | -{
|
|
116 | - wxUIMenu* menu = (wxUIMenu*) smenu;
|
|
117 | - wxMenuImpl* menuimpl = [menu implementation];
|
|
118 | - if ( menuimpl )
|
|
119 | - {
|
|
120 | - wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer();
|
|
121 | - if ( wxpeer )
|
|
122 | - wxpeer->HandleMenuClosed();
|
|
123 | - }
|
|
124 | -}
|
|
125 | - |
|
126 | -- (void)menu:(UIMenu *)smenu willHighlightItem:(UIMenuItem *)item
|
|
127 | -{
|
|
128 | - wxUIMenu* menu = (wxUIMenu*) smenu;
|
|
129 | - wxMenuImpl* menuimpl = [menu implementation];
|
|
130 | - if ( menuimpl )
|
|
131 | - {
|
|
132 | - wxMenuItem* menuitem = nullptr;
|
|
133 | - wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer();
|
|
134 | - |
|
135 | - if ( [ item isKindOfClass:[wxUIMenuItem class] ] )
|
|
136 | - {
|
|
137 | - wxMenuItemImpl* menuitemimpl = (wxMenuItemImpl*) [ (wxUIMenuItem*) item implementation ];
|
|
138 | - if ( menuitemimpl )
|
|
139 | - {
|
|
140 | - menuitem = menuitemimpl->GetWXPeer();
|
|
141 | - }
|
|
142 | - }
|
|
143 | - |
|
144 | - if ( wxpeer )
|
|
145 | - {
|
|
146 | - wxpeer->HandleMenuItemHighlighted( menuitem );
|
|
147 | - }
|
|
148 | - }
|
|
149 | -}
|
|
150 | -*/
|
|
151 | - |
|
152 | -@end
|
|
153 | - |
|
154 | -class wxMenuCocoaImpl : public wxMenuImpl
|
|
38 | +class wxMenuIPhoneImpl : public wxMenuImpl
|
|
155 | 39 | {
|
156 | 40 | public :
|
157 | - wxMenuCocoaImpl( wxMenu* peer , UIMenu* menu) : wxMenuImpl(peer), m_osxMenu(wxCFRetain(menu))
|
|
41 | + wxMenuIPhoneImpl( wxMenu* peer , UIMenu* menu) : wxMenuImpl(peer), m_osxMenu(wxCFRetain(menu))
|
|
158 | 42 | {
|
159 | - /*
|
|
160 | - static wxUIMenuController* controller = nullptr;
|
|
161 | - if ( controller == nullptr )
|
|
162 | - {
|
|
163 | - controller = [[wxUIMenuController alloc] init];
|
|
164 | - }
|
|
165 | - [menu setDelegate:controller];
|
|
166 | - [m_osxMenu setImplementation:this];
|
|
167 | - // gc aware
|
|
168 | - if ( m_osxMenu )
|
|
169 | - CFRetain(m_osxMenu);
|
|
170 | - [m_osxMenu release];
|
|
171 | - */
|
|
172 | 43 | }
|
173 | 44 | |
174 | - virtual ~wxMenuCocoaImpl();
|
|
45 | + virtual ~wxMenuIPhoneImpl();
|
|
175 | 46 | |
176 | 47 | virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos) override
|
177 | 48 | {
|
178 | 49 | UIMenuElement* uimenuitem = (UIMenuElement*) pItem->GetPeer()->GetHMenuItem();
|
179 | 50 | m_children.push_back(uimenuitem);
|
180 | - /*
|
|
181 | - // make sure a call of SetSubMenu is also reflected (occurring after Create)
|
|
182 | - // update the native menu item accordingly
|
|
183 | - |
|
184 | - if ( pItem->IsSubMenu() )
|
|
185 | - {
|
|
186 | - wxMenu* wxsubmenu = pItem->GetSubMenu();
|
|
187 | - WXHMENU nssubmenu = wxsubmenu->GetHMenu();
|
|
188 | - if ( [nsmenuitem submenu] != nssubmenu )
|
|
189 | - {
|
|
190 | - wxsubmenu->GetPeer()->SetTitle( pItem->GetItemLabelText() );
|
|
191 | - [nsmenuitem setSubmenu:nssubmenu];
|
|
192 | - }
|
|
193 | - }
|
|
194 | - |
|
195 | - if ( pos == (size_t) -1 )
|
|
196 | - [m_osxMenu addItem:nsmenuitem ];
|
|
197 | - else
|
|
198 | - [m_osxMenu insertItem:nsmenuitem atIndex:pos];
|
|
199 | - */
|
|
200 | 51 | }
|
201 | 52 | |
202 | 53 | virtual void Remove( wxMenuItem *pItem ) override
|
203 | 54 | {
|
204 | - // [m_osxMenu removeItem:(UIMenuItem*) pItem->GetPeer()->GetHMenuItem()];
|
|
205 | 55 | }
|
206 | 56 | |
207 | 57 | virtual void MakeRoot() override
|
... | ... | @@ -214,8 +64,6 @@ public : |
214 | 64 | |
215 | 65 | virtual void SetTitle( const wxString& text ) override
|
216 | 66 | {
|
217 | - // wxCFStringRef cfText(text);
|
|
218 | - // [m_osxMenu setTitle:cfText.AsNSString()];
|
|
219 | 67 | }
|
220 | 68 | |
221 | 69 | virtual void PopUp( wxWindow *win, int x, int y ) override
|
... | ... | @@ -271,29 +119,38 @@ public : |
271 | 119 | |
272 | 120 | void DisableAutoEnable()
|
273 | 121 | {
|
274 | - /*
|
|
275 | - [m_osxMenu setAutoenablesItems:NO];
|
|
276 | - |
|
277 | - wxMenu* menu = GetWXPeer();
|
|
278 | - for ( wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
|
|
279 | - node;
|
|
280 | - node = node->GetNext() )
|
|
281 | - {
|
|
282 | - const wxMenuItem* const item = node->GetData();
|
|
283 | - if ( item->IsSubMenu() )
|
|
284 | - {
|
|
285 | - wxMenuCocoaImpl* subimpl = dynamic_cast<wxMenuCocoaImpl*>(item->GetSubMenu()->GetPeer());
|
|
286 | - if ( subimpl )
|
|
287 | - subimpl->DisableAutoEnable();
|
|
288 | - }
|
|
289 | - }
|
|
290 | -*/
|
|
291 | 122 | }
|
292 | 123 | |
293 | 124 | WXHMENU GetHMenu() override {
|
294 | 125 | if ( m_osxMenu == nil )
|
295 | 126 | {
|
296 | - m_osxMenu.reset( [UIMenu menuWithTitle:wxCFStringRef(m_peer->GetTitle()).AsNSString() children:m_children] );
|
|
127 | + NSString* title = wxNSStringWithWxString(wxStripMenuCodes(m_peer->GetTitle(), wxStrip_Menu));
|
|
128 | + |
|
129 | + wxCFMutableArrayRef<UIMenu*> groups;
|
|
130 | + wxCFMutableArrayRef<UIMenuElement*> currentMenuElements;
|
|
131 | + |
|
132 | + for ( int i = 0 ; i < m_children.size(); i++ )
|
|
133 | + {
|
|
134 | + UIMenuElement* element = m_children[i];
|
|
135 | + if ( element.title.length > 0 )
|
|
136 | + {
|
|
137 | + currentMenuElements.push_back(element);
|
|
138 | + }
|
|
139 | + else // separator, start a new menu group
|
|
140 | + {
|
|
141 | + UIMenu* menu = [UIMenu menuWithTitle:@"" image:nil identifier:nil options:UIMenuOptionsDisplayInline children:currentMenuElements];
|
|
142 | + currentMenuElements.clear();
|
|
143 | + groups.push_back(menu);
|
|
144 | + }
|
|
145 | + }
|
|
146 | + if ( !currentMenuElements.empty() )
|
|
147 | + {
|
|
148 | + UIMenu* menu = [UIMenu menuWithTitle:@"" image:nil identifier:nil options:UIMenuOptionsDisplayInline children:currentMenuElements];
|
|
149 | + currentMenuElements.clear();
|
|
150 | + groups.push_back(menu);
|
|
151 | + }
|
|
152 | + |
|
153 | + m_osxMenu.reset( [UIMenu menuWithTitle:title children:groups] );
|
|
297 | 154 | }
|
298 | 155 | return m_osxMenu;
|
299 | 156 | }
|
... | ... | @@ -303,25 +160,70 @@ public : |
303 | 160 | protected :
|
304 | 161 | wxCFRef<UIMenu*> m_osxMenu;
|
305 | 162 | wxCFMutableArrayRef<UIMenuElement*> m_children;
|
306 | - |
|
307 | -/*
|
|
308 | - UIMenu* menu = [[UIMenu menuWithTitle:cfText.AsNSString() children:];
|
|
309 | -*/
|
|
310 | - |
|
311 | 163 | } ;
|
312 | 164 | |
313 | -wxMenuCocoaImpl::~wxMenuCocoaImpl()
|
|
165 | +wxMenuIPhoneImpl::~wxMenuIPhoneImpl()
|
|
314 | 166 | {
|
315 | - // [m_osxMenu setDelegate:nil];
|
|
316 | - // [m_osxMenu setImplementation:nil];
|
|
317 | - // gc aware
|
|
318 | 167 | }
|
319 | 168 | |
320 | 169 | wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title )
|
321 | 170 | {
|
322 | 171 | wxCFStringRef cfText( title );
|
323 | - wxMenuImpl* c = new wxMenuCocoaImpl( peer, nil );
|
|
172 | + wxMenuImpl* c = new wxMenuIPhoneImpl( peer, nil );
|
|
324 | 173 | return c;
|
325 | 174 | }
|
326 | 175 | |
176 | +#if wxUSE_MENUBAR
|
|
177 | +void wxMenuBar::OSXOnBuildMenu(WX_NSObject b)
|
|
178 | +{
|
|
179 | + id<UIMenuBuilder> builder = (id<UIMenuBuilder>) b;
|
|
180 | + |
|
181 | + UIMenuIdentifier lastmenuid = UIMenuApplication;
|
|
182 | + |
|
183 | + [builder removeMenuForIdentifier:UIMenuFile];
|
|
184 | + [builder removeMenuForIdentifier:UIMenuEdit];
|
|
185 | + [builder removeMenuForIdentifier:UIMenuFormat];
|
|
186 | + [builder removeMenuForIdentifier:UIMenuView];
|
|
187 | + |
|
188 | + NSString* nsHelpMenuTitle = wxNSStringWithWxString(wxStripMenuCodes(wxApp::s_macHelpMenuTitleName, wxStrip_Menu));
|
|
189 | + NSString* nsTranslatedHelpTitle = wxNSStringWithWxString(wxGETTEXT_IN_CONTEXT("macOS menu name", "Help"));
|
|
190 | + |
|
191 | + NSString* nsWindowMenuTitle = wxNSStringWithWxString(wxStripMenuCodes(wxApp::s_macWindowMenuTitleName, wxStrip_Menu));
|
|
192 | + NSString* nsTranslatedWindowMenuTitle = wxNSStringWithWxString(wxGETTEXT_IN_CONTEXT("macOS menu name", "Window"));
|
|
193 | + |
|
194 | + |
|
195 | + for ( wxMenuItemList::compatibility_iterator node = m_rootMenu->GetMenuItems().GetFirst();
|
|
196 | + node;
|
|
197 | + node = node->GetNext() )
|
|
198 | + {
|
|
199 | + const wxMenuItem* const item = node->GetData();
|
|
200 | + if ( item->IsSubMenu() )
|
|
201 | + {
|
|
202 | + UIMenu* menu = (UIMenu *)item->GetSubMenu()->GetHMenu();
|
|
203 | + |
|
204 | + if ( item->GetSubMenu() == m_appleMenu )
|
|
205 | + {
|
|
206 | + // the default is quite resonable
|
|
207 | + // TODO merge non desktop commands into the application menu, discard the rest
|
|
208 | + }
|
|
209 | + else if ([[menu title] isEqualToString:nsWindowMenuTitle] ||
|
|
210 | + [[menu title] isEqualToString:nsTranslatedWindowMenuTitle])
|
|
211 | + {
|
|
212 | + [builder replaceMenuForIdentifier:UIMenuWindow withMenu:menu];
|
|
213 | + }
|
|
214 | + else if ([[menu title] isEqualToString:nsHelpMenuTitle] ||
|
|
215 | + [[menu title] isEqualToString:nsTranslatedHelpTitle])
|
|
216 | + {
|
|
217 | + [builder replaceMenuForIdentifier:UIMenuHelp withMenu:menu];
|
|
218 | + }
|
|
219 | + else
|
|
220 | + {
|
|
221 | + [builder insertSiblingMenu:menu afterMenuForIdentifier:(UIMenuIdentifier) lastmenuid];
|
|
222 | + }
|
|
223 | + lastmenuid = menu.identifier;
|
|
224 | + }
|
|
225 | + }
|
|
226 | +}
|
|
227 | +#endif
|
|
228 | + |
|
327 | 229 | #endif |
... | ... | @@ -182,14 +182,14 @@ void wxMacCocoaMenuItemSetAccelerator( UIMenuItem* menuItem, wxAcceleratorEntry* |
182 | 182 | |
183 | 183 | */
|
184 | 184 | |
185 | -class wxMenuItemCocoaImpl : public wxMenuItemImpl
|
|
185 | +class wxMenuItemIPhoneImpl : public wxMenuItemImpl
|
|
186 | 186 | {
|
187 | 187 | public :
|
188 | - wxMenuItemCocoaImpl( wxMenuItem* peer, UIMenuElement* item ) : wxMenuItemImpl(peer), m_osxMenuItem(wxCFRetain(item))
|
|
188 | + wxMenuItemIPhoneImpl( wxMenuItem* peer, UIMenuElement* item ) : wxMenuItemImpl(peer), m_osxMenuItem(wxCFRetain(item))
|
|
189 | 189 | {
|
190 | 190 | }
|
191 | 191 | |
192 | - ~wxMenuItemCocoaImpl();
|
|
192 | + ~wxMenuItemIPhoneImpl();
|
|
193 | 193 | |
194 | 194 | void SetBitmap( const wxBitmapBundle& bitmap ) override
|
195 | 195 | {
|
... | ... | @@ -244,11 +244,11 @@ protected : |
244 | 244 | wxCFRef<UIMenuElement*> m_osxMenuItem ;
|
245 | 245 | } ;
|
246 | 246 | |
247 | -wxMenuItemCocoaImpl::~wxMenuItemCocoaImpl()
|
|
247 | +wxMenuItemIPhoneImpl::~wxMenuItemIPhoneImpl()
|
|
248 | 248 | {
|
249 | 249 | }
|
250 | 250 | |
251 | -bool wxMenuItemCocoaImpl::DoDefault()
|
|
251 | +bool wxMenuItemIPhoneImpl::DoDefault()
|
|
252 | 252 | {
|
253 | 253 | bool handled=false;
|
254 | 254 | int menuid = m_peer->GetId();
|
... | ... | @@ -291,7 +291,8 @@ wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu, |
291 | 291 | |
292 | 292 | if ( kind == wxITEM_SEPARATOR )
|
293 | 293 | {
|
294 | - // TODO new version of item = [[UIMenuItem separatorItem] retain];
|
|
294 | + UIAction* menuItem = [UIAction actionWithTitle:@"" image:nil identifier:nil handler: ^( UIAction* action) {} ];
|
|
295 | + item = menuItem;
|
|
295 | 296 | }
|
296 | 297 | else
|
297 | 298 | {
|
... | ... | @@ -305,12 +306,14 @@ wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu, |
305 | 306 | }
|
306 | 307 | else
|
307 | 308 | {
|
309 | + wxString identifier = wxString::Format( wxT("%p"), peer );
|
|
310 | + wxCFStringRef cfidentifier(identifier);
|
|
308 | 311 | // currently in the iOS 14 Beta UICommands trigger a layout violation so stick with UIActions for the time being
|
309 | 312 | if ( entry )
|
310 | 313 | {
|
311 | 314 | // TODO UIKeyCommand* command = [UIKeyCommand commandWithTitle ...]
|
312 | 315 | |
313 | - UIAction* menuitem = [UIAction actionWithTitle:cfText.AsNSString() image:nil identifier:nil
|
|
316 | + UIAction* menuitem = [UIAction actionWithTitle:cfText.AsNSString() image:nil identifier:cfidentifier.AsNSString()
|
|
314 | 317 | handler: ^( UIAction* action) { peer->GetMenu()->HandleCommandProcess(peer);} ];
|
315 | 318 | item = menuitem;
|
316 | 319 | }
|
... | ... | @@ -320,13 +323,13 @@ wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu, |
320 | 323 | UICommand* command = [UICommand commandWithTitle:cfText.AsNSString() image:nil action:@selector(menuItemAction:) propertyList:nil];
|
321 | 324 | */
|
322 | 325 | |
323 | - UIAction* menuitem = [UIAction actionWithTitle:cfText.AsNSString() image:nil identifier:nil
|
|
326 | + UIAction* menuitem = [UIAction actionWithTitle:cfText.AsNSString() image:nil identifier:cfidentifier.AsNSString()
|
|
324 | 327 | handler: ^( UIAction* action) { peer->GetMenu()->HandleCommandProcess(peer);} ];
|
325 | 328 | item = menuitem;
|
326 | 329 | }
|
327 | 330 | }
|
328 | 331 | }
|
329 | - c = new wxMenuItemCocoaImpl( peer, item );
|
|
332 | + c = new wxMenuItemIPhoneImpl( peer, item );
|
|
330 | 333 | return c;
|
331 | 334 | }
|
332 | 335 |
... | ... | @@ -42,7 +42,7 @@ |
42 | 42 | // Common Event Support
|
43 | 43 | // ----------------------------------------------------------------------------
|
44 | 44 | |
45 | -@interface wxAppDelegate : NSObject <UIApplicationDelegate> {
|
|
45 | +@interface wxAppDelegate : UIResponder <UIApplicationDelegate> {
|
|
46 | 46 | }
|
47 | 47 | |
48 | 48 | @end
|
... | ... | @@ -57,19 +57,31 @@ |
57 | 57 | return YES;
|
58 | 58 | }
|
59 | 59 | |
60 | -- (void)applicationDidFinishLaunching:(UIApplication *)application {
|
|
60 | +- (void)applicationDidFinishLaunching:(UIApplication *)application
|
|
61 | +{
|
|
61 | 62 | wxTheApp->OSXOnDidFinishLaunching();
|
62 | 63 | }
|
63 | 64 | |
64 | -- (void)applicationWillTerminate:(UIApplication *)application {
|
|
65 | +- (void)applicationWillTerminate:(UIApplication *)application
|
|
66 | +{
|
|
65 | 67 | wxUnusedVar(application);
|
66 | 68 | wxTheApp->OSXOnWillTerminate();
|
67 | 69 | }
|
68 | 70 | |
69 | -- (void)dealloc {
|
|
71 | +- (void)dealloc
|
|
72 | +{
|
|
70 | 73 | [super dealloc];
|
71 | 74 | }
|
72 | 75 | |
76 | +#if wxUSE_MENUBAR
|
|
77 | +- (void) buildMenuWithBuilder:(id<UIMenuBuilder>) builder
|
|
78 | +{
|
|
79 | + if ( builder.system == UIMenuSystem.mainSystem )
|
|
80 | + {
|
|
81 | + wxTheApp->OSXOnBuildMenu((WX_NSObject) builder);
|
|
82 | + }
|
|
83 | +}
|
|
84 | +#endif
|
|
73 | 85 | |
74 | 86 | @end
|
75 | 87 |
... | ... | @@ -665,11 +665,13 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) |
665 | 665 | |
666 | 666 | bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
|
667 | 667 | {
|
668 | + // must be set early because base class method call might call back and create a native menu which would be missing a title
|
|
669 | + menu->SetTitle(title);
|
|
670 | + |
|
668 | 671 | if ( !wxMenuBarBase::Insert(pos, menu, title) )
|
669 | 672 | return false;
|
670 | 673 | |
671 | 674 | m_rootMenu->Insert( pos+firstMenuPos, wxMenuItem::New( m_rootMenu, wxID_ANY, title, "", wxITEM_NORMAL, menu ) );
|
672 | - menu->SetTitle(title);
|
|
673 | 675 | |
674 | 676 | return true;
|
675 | 677 | }
|
... | ... | @@ -688,6 +690,9 @@ wxMenu *wxMenuBar::Remove(size_t pos) |
688 | 690 | |
689 | 691 | bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
|
690 | 692 | {
|
693 | + // must be set early because base class method call might call back and create a native menu which would be missing a title
|
|
694 | + menu->SetTitle(title);
|
|
695 | + |
|
691 | 696 | WXHMENU submenu = menu ? menu->GetHMenu() : nullptr;
|
692 | 697 | wxCHECK_MSG( submenu, false, wxT("can't append invalid menu to menubar") );
|
693 | 698 | |
... | ... | @@ -695,7 +700,6 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title) |
695 | 700 | return false;
|
696 | 701 | |
697 | 702 | m_rootMenu->AppendSubMenu(menu, title);
|
698 | - menu->SetTitle(title);
|
|
699 | 703 | |
700 | 704 | return true;
|
701 | 705 | }
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help