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).

nspopupbutton in toolbar

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

screenshot


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -