Re: keyboard events
Re: keyboard events
- Subject: Re: keyboard events
- From: Liam Whalen <email@hidden>
- Date: Wed, 12 Sep 2007 00:31:06 -0400
On 11-Sep-07, at 11:29 PM, David Rio Deiros wrote:
On Tue, Sep 11, 2007 at 06:04:38PM +0200, Manfred Schwind wrote:
I have a very basic cocoa application that has an NSTextField, a
couple of buttons and a scroll view.
The user enters some word in the textfield, then clicks one of the
buttons and the application writes
something to the scroll view. The other button just cleans the
scroll view.
The application works fine, but now I want to add some code so
after entering the word the user can
hit <enter> and then the results get generated in the scroll view
(same as if he/she press the "execute"
button).
I don't have much experience with Cocoa and there are probably a
multitude of reasons why you shouldn't do what I'm about to suggest.
However, why not use an NSFormatter?
- (BOOL) isPartialStringValid:(NSString*) partialString
newEditingString:(NSString**) newString errorDescription:(NSString**)
error
{
//You'll probably have to change this I'm not sure if '\n' is what
you want. What ever enter is represented as in NSString is what you
want
//I just did a quick look but couldn't find it.
NSRange locationOfEnter = [partialString rangeOfString: @"\n"];
//check to see if there was a \n found. If there was the length
will be > 0 otherwise it will be 0
if (locationOfEnter.length > 0)
{
//execute your code here to update the scroll view
}
}
Liam
_______________________________________________
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