diff -r b72c6db6890b -r 5dc02b23752f src/gui/widgets/qcocoamenu_mac.mm --- a/src/gui/widgets/qcocoamenu_mac.mm Wed Jun 23 19:07:03 2010 +0300 +++ b/src/gui/widgets/qcocoamenu_mac.mm Tue Jul 06 15:10:48 2010 +0300 @@ -46,6 +46,7 @@ #import #include #include +#include #include @@ -70,6 +71,7 @@ self = [super init]; if (self) { qmenu = menu; + previousAction = 0; [self setAutoenablesItems:NO]; [self setDelegate:self]; } @@ -81,13 +83,20 @@ Q_UNUSED(menu); if (!item) { - // ### According to the docs everything will be highlighted. Not sure what we should do in - // Qt, so just return. + if (previousAction) { + qt_mac_clear_status_text(previousAction); + previousAction = 0; + } return; } - if (QAction *action = reinterpret_cast([item tag])) + if (QAction *action = reinterpret_cast([item tag])) { + QMenu *qtmenu = static_cast(menu)->qmenu; + previousAction = action; action->activate(QAction::Hover); + qt_mac_menu_emit_hovered(qtmenu, action); + action->showStatusText(0); // 0 widget -> action's parent + } } - (void)menuWillOpen:(NSMenu*)menu; @@ -100,9 +109,13 @@ qt_mac_menu_collapseSeparators(menu, qtmenu->separatorsCollapsible()); } -- (void)menuWillClose:(NSMenu*)menu; +- (void)menuDidClose:(NSMenu*)menu; { qt_mac_emit_menuSignals(((QT_MANGLE_NAMESPACE(QCocoaMenu) *)menu)->qmenu, false); + if (previousAction) { + qt_mac_clear_status_text(previousAction); + previousAction = 0; + } } - (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteger)modifier @@ -194,6 +207,18 @@ } qt_mac_menus_open_count += delta; } + +void qt_mac_clear_status_text(QAction *action) +{ + action->d_func()->showStatusText(0, QString()); +} + +void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action) +{ + emit menu->hovered(action); +} + + QT_END_NAMESPACE #endif