summaryrefslogtreecommitdiff
path: root/vcl/osx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/osx')
-rw-r--r--vcl/osx/salmenu.cxx42
-rw-r--r--vcl/osx/salnsmenu.mm15
2 files changed, 16 insertions, 41 deletions
diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx
index 5119d6cf8f13..91a5c2e46279 100644
--- a/vcl/osx/salmenu.cxx
+++ b/vcl/osx/salmenu.cxx
@@ -317,37 +317,6 @@ AquaSalMenu::~AquaSalMenu()
}
}
-sal_Int32 removeUnusedItemsRunner(NSMenu * pMenu)
-{
- NSArray * elements = [pMenu itemArray];
- NSEnumerator * it = [elements objectEnumerator];
- id elem;
- NSMenuItem * lastDisplayedMenuItem = nil;
- sal_Int32 drawnItems = 0;
- bool firstEnabledItemIsNoSeparator = false;
- while((elem=[it nextObject]) != nil) {
- NSMenuItem * item = static_cast<NSMenuItem *>(elem);
- if( (![item isEnabled] && ![item isSeparatorItem]) || ([item isSeparatorItem] && (lastDisplayedMenuItem != nil && [lastDisplayedMenuItem isSeparatorItem])) ) {
- [[item menu]removeItem:item];
- } else {
- if( ! firstEnabledItemIsNoSeparator && [item isSeparatorItem] ) {
- [[item menu]removeItem:item];
- } else {
- firstEnabledItemIsNoSeparator = true;
- lastDisplayedMenuItem = item;
- drawnItems++;
- if( [item hasSubmenu] ) {
- removeUnusedItemsRunner( [item submenu] );
- }
- }
- }
- }
- if( lastDisplayedMenuItem != nil && [lastDisplayedMenuItem isSeparatorItem]) {
- [[lastDisplayedMenuItem menu]removeItem:lastDisplayedMenuItem];
- }
- return drawnItems;
-}
-
bool AquaSalMenu::ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle& rRect, FloatWinPopupFlags nFlags)
{
// do not use native popup menu when AQUA_NATIVE_MENUS is set to false
@@ -365,13 +334,6 @@ bool AquaSalMenu::ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle& rR
NSView* pPopupNSView = static_cast<AquaSalFrame *>(pWin->ImplGetWindow()->ImplGetFrame())->mpNSView;
NSRect popupFrame = [pPopupNSView frame];
- // since we manipulate the menu below (removing entries)
- // let's rather make a copy here and work with that
- NSMenu* pCopyMenu = [mpMenu copy];
-
- // filter disabled elements
- removeUnusedItemsRunner( pCopyMenu );
-
// create frame rect
NSRect displayPopupFrame = NSMakeRect( rRect.Left()+(offset-1), rRect.Top()+(offset+1), popupFrame.size.width, 0 );
pParentAquaSalFrame->VCLToCocoa(displayPopupFrame, false);
@@ -390,15 +352,13 @@ bool AquaSalMenu::ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle& rR
// open popup menu
NSPopUpButtonCell * pPopUpButtonCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO];
- [pPopUpButtonCell setMenu: pCopyMenu];
+ [pPopUpButtonCell setMenu: mpMenu];
[pPopUpButtonCell selectItem:nil];
[AquaA11yWrapper setPopupMenuOpen: YES];
[pPopUpButtonCell performClickWithFrame:displayPopupFrame inView:pParentNSView];
[pPopUpButtonCell release];
[AquaA11yWrapper setPopupMenuOpen: NO];
- // clean up the copy
- [pCopyMenu release];
return true;
}
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]];
+ }
+ }
}
}