Change the image of the search button cell in NSSearchField

720 Views Asked by At

I have a NSToolbar which contains a NSSearchField.

I have changed the image of the search button cell (in awakeFromNib) to one that more accurately describes what I am doing.

Unfortunately, if the user customises the toolbar the default image is restored.

How can I either a) prevent Customisation, but still allow the user to select icons and/or text b) detect the change, so I can restore the desired icon c) change the image on the default

1

There are 1 best solutions below

2
On

Maybe b

Use NSToolbar Delegate and implement

- (NSToolbarItem *) toolbar:(NSToolbar *)toolbar
      itemForItemIdentifier:(NSString *)itemIdentifier
  willBeInsertedIntoToolbar:(BOOL)flag

There you could give back your custom Item.