Re: How to use a button to update an application with a text field value
Re: How to use a button to update an application with a text field value
- Subject: Re: How to use a button to update an application with a text field value
- From: Ken Thomases <email@hidden>
- Date: Wed, 6 Aug 2008 21:53:12 -0500
On Aug 6, 2008, at 9:39 PM, Tron Thomas wrote:
The only the the controller's action does in response to the button
action is call commitEditing.
And that's the problem. You're overloading the text field's binding
to your model with semantics of a user action, when it's not.
The action triggered by the button should explicitly do your game
logic (check the user's answer, give them points, advance them to the
next question, etc.).
I'm not sure what you mean by having the text field use the same
action. I don't see any action method in the Interface Builder
connection dialog for the text field. There is something called
selector, I'm not sure what that is for.
When you hit return in a text field, it fires off an action to its
target. This is conceptually just like when you click a button. In
IB, you set up the target-action in the same way. You control-drag
from the text field to the target, and then select the action
(selector) in the target.
Note that hitting return _does_ carry the semantics of a user action,
and so would be an appropriate occasion for your game to check the
user's answer and give them points, or whatever. That's why I
recommend that the text field be set up to invoke the same action on
the same target as the button. Both should do the same thing.
In this case, the user interface is so simple there is no need to
worry about the user tabbing to another control. There is no other
control they can tab to.
You're wrong. Look in System Preferences > Keyboard & Mouse >
Keyboard Shortcuts. There's a setting called Full Keyboard Access
which a user can configure to allow them to tab among all controls in
a window, not just text fields. So, the mere existence of a button in
the window is enough to allow the user to tab away from your text
field. That would update the binding but should not (in my opinion)
count as them entering their answer.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden