Re: Edit NSTokenField's token?

  • Hi,

    Unfortunately the double-click editing of tokens is not possible on
    Tiger. I ended up with a menu with an edit item that tries to bring
    it back in editing mode again (tricky). Good news is that double-
    click editing is there in Leopard now, however be aware that for some
    (compatibility) reason you has to build against the 10.5 SDK to get
    this behaviour. If you do the tokenfield still won't have double-
    click editing on Tiger, but it does on Leopard.

    Regarding the menus, I don't think linking to a menu in IB will work,
    you can great an IBOutlet from your class to get a variable in your
    code pointing to the menu in your nib, and then return that in
    tokenField:hasMenuForRepresentedObject:
    Hope that helps,
    Alex

    > FROM : Daniel Ström
    > DATE : Fri Dec 07 08:35:38 2007
    >
    > 25 jul 2006 kl. 14.14.54 skrev Fredrik Olsson:
    >
    >> Mail allows the user to edit a token by double clicking it, or
    >> selecting edit from the token's menu.
    >>
    >> This behavior is not default for NSTokenField. Searching this
    >> mailing list and all mighty Google yields quite a few questions on
    >> this topic, but no answers unfortunately :(.
    >>
    >> Is there a way to let the user edit an existing token, instead of
    >> deleting and retyping?
    >>
    >> Tokens are highlighted when hovering the mouse (even when disabled,
    >> should this be a bug?), but I can not find a reference in the
    >> documentation for how to catch these events, or even selection of
    >> tokens. Browsing the NSTokenField and NSTokenFieldCell classes with
    >> the F-Script object browser do not reveal any obvious mehods for
    >> manipulating individual tokens. Am I missing something obvious, or
    >> does not Mail use NSTokenField at all?
    >>
    >>
    >> // Fredrik Olssn
    >
    >
    > I have also been looking for an answer to this question, but to no
    > avail. I am currently writing an application where I need this menu to
    > contain categories/properties for the tokens. When I click on the menu
    > for a token, then the token is used as a key into a dictionary, to
    > find the value, which contains the category/property to be changed.
    >
    > My problem is that I don't get the menu for the token to show up att
    > all. In IB one can right-click on NSTokenFiled or NSTokenFieldCell and
    > connect to a menu, but that doesn't work. I have also implemented
    > tokenField:hasMenuForRepresentedObject: and
    > tokenField:menuForRepresentedObject: in my code, and set that code to
    > be the delegate for the NSTokenField or NSTokenFieldCell. I've tried
    > both of them.
    >
    > Why is my menu not showing up?
    >
    > Best regards
    > Daniel Strom
  • Hi,

    I'm "resurrecting" this old thread (from late 2007!) to see whether
    someone succeeded in reproducing Apple Mail's ability to turn any
    given token into "editable plain text" mode.  (I'm here talking about
    the behaviour of Apple Mail's "Edit Address" token-based menu item.)

    Alexander Griekspoor (hi!) seemed to reply so to Fredrik Olsson (hi!)
    [relevant tidbits copied below], and I'd love to hear anyone willing
    to share some more details 'cause my initial attempts+websearches
    didn't lead me to good results so far :( !  [Note: It was very easy to
    add this "Edit" token-based menu item to my tokens; but its dedicated
    action is lacking the li'l "trick" that would turn the corresponding
    token back to (editable) plain text…]

    Thanks in advance,

    --
    — Fred

    ===

    25 jul 2006 kl. 14.14.54 skrev Fredrik Olsson:
    >> Mail allows the user to edit a token by (…) selecting edit from the
    >> token's menu.
    >>
    >> This behavior is not default for NSTokenField. (…)
    >>
    >> Is there a way to let the user edit an existing token, instead of
    >> deleting and retyping?
    >>
    >> Tokens are highlighted when hovering the mouse (…), but I can not find
    >> a reference in the documentation for how to catch these events, or even
    >> selection of tokens.

    On Fri, Dec 7, 2007 at 10:09 AM, Alexander Griekspoor (…) wrote:
    > Unfortunately the double-click editing of tokens is not possible on Tiger. I
    > ended up with a menu with an edit item that tries to bring it back in
    > editing mode again (tricky). (…)
previous month december 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