2

I would like to add an image (Canadian flag) on the right side of the IP address (near the right edge of the menu) and the NSProgressIndicator to the left of the word 'Updating...'.

Can this be done in the view designer or does it need to be done in code? A detailed explanation of either approach would be appreciated.

enter image description here

craig
  • 25,664
  • 27
  • 119
  • 205
  • I think this can be done either way, although I think code would give you more control of the customization. NSMenuItem has a view property that you can set. So just create that custom view and then set it. – rocky Apr 11 '14 at 19:21

1 Answers1

1

I needed to do the same thing for a project and used the setView: property.

enter image description here

Community
  • 1
  • 1
Oath Comrade
  • 283
  • 2
  • 9
  • 1
    Would you mind posting some code? How much of it were you able to do in IB? – craig Apr 16 '14 at 18:16
  • You don't have to code everything. The NSMenuItem has a Outlet called "view". That's the custom view you can bind in IB. So drag and drop a NSView into IB and design this view as you desire. Then bind it to the NSMenuItem. – Oath Comrade Apr 17 '14 at 19:36
  • So, the `NSCustomView` replaces the entire `NSMenuItem` content? So I would need to add a `NSProgressIndicator` and `NSTextField`? – craig Apr 21 '14 at 11:51
  • Yes put everything in you custom view as you please. – Oath Comrade Apr 28 '14 at 09:10
  • @OathComrade: Is your NSProgressIndicator updated while the menu is opened? I've codes exactly this, but my NSProgressIndicator isn't... – Frog May 22 '14 at 18:53
  • @Frog This might help: http://stackoverflow.com/questions/6301338/update-nsmenuitem-while-the-host-menu-is-shown – Oath Comrade May 25 '14 at 09:17
  • @OathComrade: My code is already running in `NSRunLoopCommonModes`, and a `NSTextField` **is** updated correctly. But somehow the progress indicator doesn't update. I've [asked a question](http://stackoverflow.com/questions/23833929/nsprogressindicator-in-nsmenuitem-not-updating-on-second-display) about my problem, but thus far no responses... Any ideas? – Frog May 25 '14 at 12:21