Non clickable NSToolbarItem label

  • Hi,
    I add a NSButton to the toolbar.
    If the user clicks on the NSToolbarItem icon I get the proper action.
    But I cannot get any action when the user clicks on the label of the
    NSToolbarItem. Instead, if I set just the image with
    [item setImage:anImage]], the label is properly clickable. But I get a
    distorted and smaller button. What do I miss?

    id item = [[[NSToolbarItem alloc] initWithItemIdentifier:name] autorelease];
        [item setPaletteLabel:name];
        [item setLabel:name];

        // if I use this, the label showing the name is clickable
        // but the icons are distorted, even setting min and max size
        [item setImage:[itemView image]];

        // instead if I use this, the label showing the name is not clickable
        // the icons are shown with the right size.
        [item setView:itemView];

        // no matter if I add this
        SEL  act = [itemView action];
        id    tar = [itemView target];
        if(act && tar){
            [item setAction:act];
            [item setTarget:tar];
        }

    Best Regards
    --
    Lorenzo
    email: <archidea...>
  • I did set the size too, but no luck in case of setImage.
    Instead in case of setView, yes, "set size" has effect.

    Best Regards
    --
    Lorenzo
    email: <archidea...>

    > From: David Spooner <dave...>
    > Date: Sun, 28 Oct 2007 08:24:24 -0600
    > To: Lorenzo <archidea...>
    > Subject: Re: Non clickable NSToolbarItem label
    >
    > I don't know if this will help, but I have often had to set the min
    > and max size of the item in order for it to appear properly.
    >
    > dave
    >
    > On 28-Oct-07, at 1:29 AM, Lorenzo wrote:
    >
    >> Hi,
    >> I add a NSButton to the toolbar.
    >> If the user clicks on the NSToolbarItem icon I get the proper action.
    >> But I cannot get any action when the user clicks on the label of the
    >> NSToolbarItem. Instead, if I set just the image with
    >> [item setImage:anImage]], the label is properly clickable. But I get a
    >> distorted and smaller button. What do I miss?
    >>
    >> id item = [[[NSToolbarItem alloc] initWithItemIdentifier:name]
    >> autorelease];
    >> [item setPaletteLabel:name];
    >> [item setLabel:name];
    >>
    >> // if I use this, the label showing the name is clickable
    >> // but the icons are distorted, even setting min and max size
    >> [item setImage:[itemView image]];
    >>
    >> // instead if I use this, the label showing the name is not
    >> clickable
    >> // the icons are shown with the right size.
    >> [item setView:itemView];
    >>
    >> // no matter if I add this
    >> SEL  act = [itemView action];
    >> id    tar = [itemView target];
    >> if(act && tar){
    >> [item setAction:act];
    >> [item setTarget:tar];
    >> }
    >>
    >>
    >>
    >> Best Regards
    >> --
    >> Lorenzo
    >> email: <archidea...>
    >>
    >
  • > If the user clicks on the NSToolbarItem icon I get the proper action.
    > But I cannot get any action when the user clicks on the label of the
    > NSToolbarItem.


    > // no matter if I add this
    > SEL  act = [itemView action];
    > id    tar = [itemView target];
    > if(act && tar){
    > [item setAction:act];
    > [item setTarget:tar];
    > }

    Is the button targeted at the first responder here? Your setTarget:/
    setAction: pair would never be called if that were the case.

    -Ben
previous month october 2007 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