textfield for registering hotkey

Discussion in 'Mac Programming' started by monsieurpaul, May 4, 2011.

  1. macrumors regular

    Joined:
    Oct 8, 2009
    #1
    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 but I don't know if there are more straightforward solutions.

    Thanks,

    Paul
     
  2. macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #2
    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
     
  3. thread starter macrumors regular

    Joined:
    Oct 8, 2009
    #3
    Thank you. That did it. In addition, I have found this tutorial pretty useful.
     

Share This Page