• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Making an NSMenu "small"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making an NSMenu "small"?


  • Subject: Re: Making an NSMenu "small"?
  • From: Matt Gemmell <email@hidden>
  • Date: Mon, 27 Jan 2003 17:05:02 +0000

On Monday, January 27, 2003, at 03:25 pm, Stiphane Sudre wrote:

You might not like my solution... but it is not so silly

Just tried this as I'm also interested by a solution to this. It's not working.

2) If you keep the NSPopUpButton, when you display the menu in the NSButton, the labels are big. Then if you click on the NSPopUpButton, the labels are small the next time you display the menu of the NSButton.

This leads to make me think the "smallification" of the menu labels is done in the method to draw the PopUp Menu of PopUpButton not before.

Exactly; I couldn't have said it better myself. I'd tried Jerome's method a couple of days ago, creating an NSPopUpButton instance variable within my NSButton subclass. The popupbutton's menu only becomes small immediately before the first time it's displayed by the popupbutton itself (after the popupbutton has received a mouseDown). Interestingly, if you set a small popupbutton's menu to [NSApp mainMenu], then click the popupbutton to "smallify" the menu, if you then go into the actual menubar, all the items are in small text there too.

The one thing I haven't tried yet is the following. But be warned: it's incredibly, amazingly ugly.

1. Within the NSButton subclass, create an NSPopUpButton as an instance variable, and initialize it with NSZeroRect as the frame.

2. Add your menu to the NSPopUpButton, using the standard methods of that class.

3. Add the popupbutton to your window (or whatever), positioned at the origin of where your actual NSButton subclass is showing (i.e. set both controls to have the same frame origin). The popupbutton won't actually display anything, since its size is zero.

4. Make sure the popupbutton won't receive keyboard focus at any time. Maybe use a subclass to override acceptsFirstResponder to return NO.

4. In the mouseDown handler for the NSButton, send mouseDown to the popupbutton, using the same event.

That *might* work. You'd also need to implement wrapper methods to let you add items to your "NSButton's" menu, which call equivalent methods of the NSPopUpButton.

Nasty business. NSMenu should support something like NSCell's setControlSize: method, even though it's obviously not a cell. In any case, I really think we should be able to get this (standard) functionality without this kind of hackery-pokery, or without resorting to Carbon.


Best,
-Matt

--
Matt Gemmell
Scotland Software
http://www.scotlandsoftware.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Making an NSMenu "small"? (From: Stéphane Sudre <email@hidden>)

  • Prev by Date: Re: Cursor position
  • Next by Date: Re: Nib Corruption ("Inconsistencies"): Can This Nib Be Saved?
  • Previous by thread: Re: Making an NSMenu "small"?
  • Next by thread: Re: Making an NSMenu "small"?
  • Index(es):
    • Date
    • Thread