• Maxim Monastirsky's avatar
    tdf#96875 Make OS X native context menus compatible · cbd48321
    Maxim Monastirsky yazdı
    ... 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/21374Reviewed-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
    Tested-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
    cbd48321
salnsmenu.h 1.58 KB