diff options
author | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-08-13 10:27:55 (GMT) |
---|---|---|
committer | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-08-13 10:44:28 (GMT) |
commit | b52da4ab2179079a6aff95891786d2f6598048b5 (patch) | |
tree | 5e422343842469f02c47be1c2bc408df74589048 /src/gui/widgets | |
parent | 167b63d2250e7923d7b660076a80e82af07d9cdb (diff) | |
download | Qt-b52da4ab2179079a6aff95891786d2f6598048b5.zip Qt-b52da4ab2179079a6aff95891786d2f6598048b5.tar.gz Qt-b52da4ab2179079a6aff95891786d2f6598048b5.tar.bz2 |
Multiple "Edit/Special Characters" menu entries on Mac OS X (Cocoa)
Every time [NSApp setMainMenu:] is called, Cocoa will add the 'Special
Characters' item to the 'Edit' menu. Before adding a new entry it will
make sure that menu items list doesn't contain an item with the selector
'orderFrontCharacterPalette' & a 'nil' target. We need to return the
index for the first entry (we have QCocoaMenuLoader as target).
Task-number: QTBUG-12842
Reviewed-by: Denis
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qcocoamenu_mac.mm | 12 | ||||
-rw-r--r-- | src/gui/widgets/qcocoamenu_mac_p.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/gui/widgets/qcocoamenu_mac.mm index ce85919..15fae23 100644 --- a/src/gui/widgets/qcocoamenu_mac.mm +++ b/src/gui/widgets/qcocoamenu_mac.mm @@ -188,6 +188,18 @@ QT_USE_NAMESPACE return NO; } +- (NSInteger)indexOfItemWithTarget:(id)anObject andAction:(SEL)actionSelector +{ + NSInteger index = [super indexOfItemWithTarget:anObject andAction:actionSelector]; + static SEL selForOFCP = NSSelectorFromString(@"orderFrontCharacterPalette:"); + if (index == -1 && selForOFCP == actionSelector) { + // Check if the 'orderFrontCharacterPalette' SEL exists for QCocoaMenuLoader object + QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)]; + return [super indexOfItemWithTarget:loader andAction:actionSelector]; + } + return index; +} + @end QT_BEGIN_NAMESPACE diff --git a/src/gui/widgets/qcocoamenu_mac_p.h b/src/gui/widgets/qcocoamenu_mac_p.h index d6ac8c5..1a42642 100644 --- a/src/gui/widgets/qcocoamenu_mac_p.h +++ b/src/gui/widgets/qcocoamenu_mac_p.h @@ -76,6 +76,7 @@ QT_FORWARD_DECLARE_CLASS(QAction) } - (id)initWithQMenu:(QMenu*)menu; - (BOOL)menuHasKeyEquivalent:(NSMenu *)menu forEvent:(NSEvent *)event target:(id *)target action:(SEL *)action; +- (NSInteger)indexOfItemWithTarget:(id)anObject andAction:(SEL)actionSelector; @end #endif |