osx - Unable to set submenu for NSMenuItem (FinderSync extension) -
i'm trying create cascade submenu finder sync extension in swift/cocoa. have next code:
override func menuformenukind(menukind: fimenukind) -> nsmenu! { allow m = nsmenu(title: "") allow mi1 = nsmenuitem(title: "item1", action: nil, keyequivalent: "") allow mi11 = nsmenuitem(title: "item11", action: nil, keyequivalent: "") allow m2 = nsmenu(title: "") allow mi2 = nsmenuitem(title: "item2", action: nil, keyequivalent: "") m2.additem(mi2) m.additem(mi1) m.additem(mi11) m.setsubmenu(m2, foritem: mi1) homecoming m }
so i'm trying accomplish is:
item1-> item2 item11
so flat item1
, item11
menu list.
any hints?
i filed bug apple (#18810635), got response it's duplicate of (#18531883) still open.
posted re-create of filing @ openradar http://openradar.appspot.com/radar?id=5772557445758976 , tweeted developer advocate.
if knows fate of #18531883 - core raison d'ĂȘtre finder sync extensions?
i've upgraded project swift 2.0, , made working submenu. posting solution:
override func menuformenukind(menukind: fimenukind) -> nsmenu! { allow main = nsmenu() allow submenu = nsmenu() allow maindropdown = nsmenuitem(title: "some alternative group", action: nil, keyequivalent: "") main.additem(maindropdown) m.setsubmenu(submenu, foritem: maindropdown) submenu.additem(nsmenuitem(title: "option 1", action: nil, keyequivalent: "")) submenu.additem(nsmenuitem(title: "option 2", action: nil, keyequivalent: "")) homecoming main }
this work on mac os 10.11+, 10.10.5 still has bug beingness unable generate submenu. appraoch generating flat menu < 10.11, , cascade starting el capitan.
osx cocoa swift xcode6 xcode6gm
No comments:
Post a Comment