NSView in NSMenuItem

  • Hi,

    I am using the new setView method of Leopard to set the NSView of an
    NSMenuItem. However I ran into two problems I can't solve at the moment:
    1) When I set the view it works, but there is always a border around
    the view. E.g. when I have an NSView with a solid background it does
    not fill the whole NSMenuItem. There is always a border on top and
    bottom of the NSView.
    2) I am trying to add a second NSMenuItem containing an NSView that
    has got a height of about 200px. When its added to the NSMenu the
    first NSMenuItem resizes as well to a height of 200px. How can I
    prevent this?

    Best,

    Hendrik
  • On Jan 2, 2008, at 5:24 AM, Hendrik Holtmann wrote:

    > Hi,
    >
    > I am using the new setView method of Leopard to set the NSView of
    > an NSMenuItem. However I ran into two problems I can't solve at the
    > moment:
    > 1) When I set the view it works, but there is always a border
    > around the view. E.g. when I have an NSView with a solid background
    > it does not fill the whole NSMenuItem. There is always a border on
    > top and bottom of the NSView.

    Yes, there is an area above and below the menu item region which is
    drawn by the menu itself.  There is no way to remove this at present.

    > 2) I am trying to add a second NSMenuItem containing an NSView that
    > has got a height of about 200px. When its added to the NSMenu the
    > first NSMenuItem resizes as well to a height of 200px. How can I
    > prevent this?

    The most likely cause of this is that you have added the same view to
    multiple menu items.  You should be sure to remove the view from
    previous menu items with [item setView:nil] before adding the view to
    a new item.

    I hope this helps,
    -Peter
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today