textfield for registering hotkey

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

  1. monsieurpaul
    Expand Collapse
    macrumors regular

    Oct 8, 2009

    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.


  2. ulbador
    Expand Collapse
    macrumors 68000


    Feb 11, 2010
    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.


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

  3. monsieurpaul
    Expand Collapse
    thread starter macrumors regular

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

Share This Page