X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FGUI%2FFGCocoaMenuBar.mm;h=7bedc33d5abf9687ec6033d7a3e4cc39839a6e96;hb=6dd47822545bf27f69a18a2d0ccc8abf91daa8d5;hp=451fe5ed1938fbc6b273b7811072b2388eb0297e;hpb=1632c5b266747dfb3b30047fa058b957c890e4f0;p=flightgear.git diff --git a/src/GUI/FGCocoaMenuBar.mm b/src/GUI/FGCocoaMenuBar.mm index 451fe5ed1..7bedc33d5 100644 --- a/src/GUI/FGCocoaMenuBar.mm +++ b/src/GUI/FGCocoaMenuBar.mm @@ -39,6 +39,11 @@ public: MenuItemBindings itemBindings; }; +// prior to the 10.6 SDK, NSMenuDelegate was an informal protocol +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 +@protocol NSMenuDelegate +@end +#endif @interface CocoaMenuDelegate : NSObject { @private @@ -172,16 +177,9 @@ void FGCocoaMenuBar::CocoaMenuBarPrivate::menuFromProps(NSMenu* menu, SGProperty n->setBoolValue("enabled", true); } - string shortcut; - string l = n->getStringValue("label"); - string::size_type pos = l.find("("); - if (pos != string::npos) { - string full(l); - l = full.substr(0, pos); - shortcut = full.substr(pos + 1, full.size() - (pos + 2)); - } - + string l = getLocalizedLabel(n); NSString* label = stdStringToCocoa(strutils::simplify(l)); + string shortcut = n->getStringValue("key"); NSMenuItem* item; if (index >= [menu numberOfItems]) { @@ -258,7 +256,7 @@ void FGCocoaMenuBar::init() } BOOST_FOREACH(SGPropertyNode_ptr n, props->getChildren("menu")) { - NSString* label = stdStringToCocoa(n->getStringValue("label")); + NSString* label = stdStringToCocoa(getLocalizedLabel(n)); NSMenuItem* item = [mainBar itemWithTitle:label]; NSMenu* menu; @@ -304,3 +302,10 @@ void FGCocoaMenuBar::hide() { // no-op } + +void cocoaOpenUrl(const std::string& url) +{ + CocoaAutoreleasePool pool; + NSURL* nsu = [NSURL URLWithString:stdStringToCocoa(url)]; + [[NSWorkspace sharedWorkspace] openURL:nsu]; +}