• 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
Keyboard short-cuts edit field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Keyboard short-cuts edit field


  • Subject: Keyboard short-cuts edit field
  • From: Eric Long <email@hidden>
  • Date: Wed, 03 May 2006 10:08:15 -0700
  • Thread-topic: Keyboard short-cuts edit field

A couple of days ago I posted a question that didn't receive any responses.
I'm hoping this go around to phrase it better.

I see in the Keyboard & Mouse prefs in the System Preferences there is a
Keyboard Shortcuts tab that supports a kind of text cell designed for
specifying a keyboard shortcut.  It captures input and displays appropriate
symbols for modifiers and such.  This same type of field exists in Xcode for
setting key bindings.  I like the way this is done, but the specialized edit
field control is not exposed in Cocoa, so far as I can tell.

I want to implement this same functionality as a custom subclass of
NSTextField. I'm not sure what the best way to go about doing this is.

I don't know how to intercept the key events for an NSTextField, which seems
like the best way to do things here, so I opted to watch for
textDidBeginEditing and textDidEndEditing calls.  In textDidBeginEditing, I
set a timer to repeatedly call GetKeys() and set the string value of the
edit field accordingly.  In textDidEndEditing I invalidate the timer.

I also used the NSTextView delegate method -
textView:shouldChangeTextInRange:replacementString: to prevent the text from
being set outside my control.

This generally works, but conflicts with the text editor's internal
handling.  I get beeps for certain key combinations and other undesirable
behaviors.

Is there a better way to do this? If so, can you explain it to me?

If I'm on the right track, how can I alleviate the problem of the beeps and
such?


Thanks in advance for the help,


Eric



 _______________________________________________
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

  • Follow-Ups:
    • Re: Keyboard short-cuts edit field
      • From: Uli Kusterer <email@hidden>
    • Re: Keyboard short-cuts edit field
      • From: j o a r <email@hidden>
    • Re: Keyboard short-cuts edit field
      • From: Stephane Sudre <email@hidden>
  • Prev by Date: Re: Efficiently getting characters
  • Next by Date: Problems with the Release build configuration
  • Previous by thread: Re: Incorrect flipping when manually drawing NSCells (was: Fwd: -isFlipped not working right when drawing IconAndTextCell to NSImage)
  • Next by thread: Re: Keyboard short-cuts edit field
  • Index(es):
    • Date
    • Thread