NSTokenField Drag and Drop not updating value immediately via bindings?
NSTokenField Drag and Drop not updating value immediately via bindings?
- Subject: NSTokenField Drag and Drop not updating value immediately via bindings?
- From: Mike Zornek <email@hidden>
- Date: Tue, 31 Oct 2006 22:17:36 -0500
This post is also on my blog:
<http://clickablebliss.com/blog/2006/10/31/nstokenfield_drag_and_drop_not_up
dating_value_immediately_via_bindings/>
---
I'm hopeful to take advantage of `NSTokenField` in my app and to help better
understand them I created a simple test application that mimics the UI found
in System Preferences > International > Formats (tab) > Customize Date
Formats (button/sheet).
![TokenSample](http://media.clickablebliss.com/blog/images/TokenSample.png
"TokenSample")
Basically instead of listing a table of tokens like '%d' and '%a' and asking
the user to type out the format they want, they are presented with visual
tokens that they can drag into the format editor and then use the context on
the token to choose the specific format of that token, like the day of the
week.
So far my sample code works fairly well, but there is one bug and another
hack (that I'd like to replace.)
First, the UI in my sample app is all set up with bindings, so as you type
in the main editor you'll see the two results fields below update as you
type. However when you drag a token from one of the stationary token fields
(or even a token's position in the editor) change notifications aren't sent
and I'm not 100% sure the array the field is bound to is being updated
"continuously" as I've set it up. How do I make sure that drag and drops
cause value changes?
Second is an aspect of the app I have working but seems wrong. When a user
chooses one of the context menu options for a token I call
`[mainEditorTokenField setObjectValue:[mainEditorTokenField objectValue]];`
which I've seen in some other NSTokenField sample code. This basically makes
sure that when they change from "Thursday" to "Thur" the token's display is
updated. If I leave this out the display inside the token is not updated,
though I do believe the value is changed, as if you choose a new token value
using a context menu (with that code commented out) and then start typing at
the end of the field you'll see the new value in the results.
The project is online at:
http://media.clickablebliss.com/code/TokenSample.zip
If anyone with NSTokenField experience could take a look and/or offer me
some suggestions I'd be appreciative.
~ Mike
--
Work: http://ClickableBliss.com
Play: http://MikeZornek.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden