• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Handling NSTextField keyboard events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling NSTextField keyboard events


  • Subject: Re: Handling NSTextField keyboard events
  • From: William LeFevre <email@hidden>
  • Date: Tue, 1 Jun 2004 11:11:33 -0700

Thanks Yann. Your suggestion got me looking in the right direction.
Though performKeyEquivalent: allows me to intercept the up and down
arrow key presses I've had some trouble with it because it is sent by
the super view to all of my text fields and not just the one where the
user is typing.

After more research I've found:
- (BOOL)textView:(NSTextView *)aTextView
doCommandBySelector:(SEL)aSelector

Overriding this in my NSTextField subclass seems to do the trick.

William


On May 31, 2004, at 2:31 AM, Yann Bizeul wrote:

> Instead of keyDown, try using
>
> - (BOOL)performKeyEquivalent:(NSEvent *)theEvent
>
> since arrow keys are special keys not handled by keyDown.
>
> Subclass this in your NSTextField subclass and that should work
>
> Best regards,
>
> Le 31 mai 04, ` 08:37, William LeFevre a icrit :
>
>> Hello,
>> I'm creating a small application for calculating monthly mortgage
>> payments. The application uses a number of NSTextFields, all of which
>> are used to input numerical values. The default behavior for the up
>> and down arrows is to move the insertion point to the beginning and
>> end of the current string. I would like to override this behavior to
>> instead increment and decrement the value.
>> I'm at loss. I can't find a delegate which looks appropriate.
>> Subclassing NSTextField and overriding keyDown: doesn't work because
>> the text field isn't the first responder. My current suspicion is
>> that I need to create a custom field editor which looks like a scary
>> proposition.
>> Can anyone point me in the right direction?
>>
>> Thanks,
>> William
>> _______________________________________________
>> cocoa-dev mailing list | email@hidden
>> Help/Unsubscribe/Archives:
>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>> Do not post admin requests to the list. They will be ignored.
>>
>>
>>
> --
> Yann Bizeul - yann at tynsoe.org
> http://projects.tynsoe.org/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Creating cocoa frameworks
  • Next by Date: Re: Apple, Are You Listening?
  • Previous by thread: Re: Creating cocoa frameworks
  • Next by thread: Re: Problem with drawer
  • Index(es):
    • Date
    • Thread