summaryrefslogtreecommitdiff
path: root/vcl/osx/salnsmenu.mm
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-01-11 18:17:49 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2016-01-11 23:30:53 +0000
commitcbd483211e1ac9d9e724b5ba3e3e38a0c5abe55c (patch)
tree876db22c86fee55bb07b766b6c4803d295877e86 /vcl/osx/salnsmenu.mm
parent2244b1e3863a6837dbc867c51940e52b6525de43 (diff)
tdf#96875 Make OS X native context menus compatible
... with how framework::MenuBarManager works, following my work of converting context menus to use it instead of SfxPopupMenuManager (see tdf#93837). MenuBarManager sets menu item properties/select handler when the menu activates - in MenuBarManager::Activate, but it was never called for submenus. The solution is to adapt the menuNeedsUpdate delegate to call Menu::Activate. This makes submenu items work, but doesn't update their visual state (e.g. title). The reason is that AquaSalMenu::ShowNativePopupMenu is creating a copy of the NSMenu, so AquaSalMenu::SetItemText is modifying the wrong NSMenu instance. Another problem is that AquaSalMenu::ShowNativePopupMenu tries to removes (via removeUnusedItemsRunner function) all disabled items, but the correct state is set by MenuBarManager only when the menu activates. So we must handle disabled items only after MenuBarManager::Activate did its job. Turns out that we can just hide items in NSMenu instead of removing them, so no need to clone the NSMenu anymore. Change-Id: If0785b7f9d5f0ad98ced23585379039a51dc13bf Reviewed-on: https://gerrit.libreoffice.org/21374 Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com> Tested-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'vcl/osx/salnsmenu.mm')
-rw-r--r--vcl/osx/salnsmenu.mm15
1 files changed, 15 insertions, 0 deletions
diff --git a/vcl/osx/salnsmenu.mm b/vcl/osx/salnsmenu.mm
index 6bbc683fc5ec..a0de415c0cd4 100644
--- a/vcl/osx/salnsmenu.mm
+++ b/vcl/osx/salnsmenu.mm
@@ -55,6 +55,21 @@
else
OSL_FAIL( "unconnected menu" );
}
+ else if( mpMenu->mpVCLMenu )
+ {
+ mpMenu->mpVCLMenu->Activate();
+
+ // Hide disabled items
+ NSArray* elements = [pMenu itemArray];
+ NSEnumerator* it = [elements objectEnumerator];
+ id element;
+ while ( ( element = [it nextObject] ) != nil )
+ {
+ NSMenuItem* item = static_cast< NSMenuItem* >( element );
+ if( ![item isSeparatorItem] )
+ [item setHidden: ![item isEnabled]];
+ }
+ }
}
}