objective c - NSPopUpButton in a toolbar with fixed image similar to Pages.app UI -
the toolbar in pages (numbers, keynote) has nspopupbutton fixed image (irrespective of menu selected). using view debugging turns out standard nspopupbutton fixed image.
according nspopupbutton docs regarding setimage:
,
this method has no effect. image displayed in pop button cell taken selected menu item (in case of pop menu) or first menu item (in case of pull-down menu).
this means standard nspopupbutton has non-standard behaviour.
how implemented? because setimage:
has no effect, subclass nspopupbuttoncell , overriding -drawimage:withframe:inview:
has no effect (because never called).
the problem here confusion: pull down menus display menu's first menu item image/title.
don't use -setimage:
display static image in -pull down menu. instead set first element of menu image/title want display , add selection options additional menu items.
@volker absolutely correct. built-in behaviour set image setting first element in menu not using setimage:
or settitle:
.
example, https://github.com/danieljfarrell/toolbar-with-pull-down-menu
Comments
Post a Comment