PDA

View Full Version : textfield for registering hotkey




monsieurpaul
May 4, 2011, 09:32 AM
Hello,

I am looking for a type of textfield (or a particular option in NSTextFIeld) that allows to shows the modifier keys that are used. For example, the textfield would show the "⌥" glyph when I press the option key.

So far I have found external framework such as ShortcutRecoder (http://wafflesoftware.net/shortcut/) but I don't know if there are more straightforward solutions.

Thanks,

Paul



ulbador
May 4, 2011, 11:44 AM
I'm just kinda going off memory here, but you might have to subclass the NSTextField or NSTextView and override the keyDown method.

You might look at the delegate methods for controlTextDidBeginEditing, controlTextDidChange, and controlTextDidEndEditing, but those might not catch modifier keys.

Edit:

A little googling found this. In particular it mentions detecting the keydown events in a NSTextView delegate:

http://www.cocoadev.com/index.pl?NSTextField

monsieurpaul
May 4, 2011, 08:20 PM
I'm just kinda going off memory here, but you might have to subclass the NSTextField or NSTextView and override the keyDown method.

Thank you. That did it. In addition, I have found this tutorial (http://juliuspaintings.co.uk/cgi-bin/paint_css/animatedPaint/005-NSTextView.pl) pretty useful.