سؤال

In Xcode, when you are setting a keyboard shortcut, there is a nice control that helps you out:

UI Control

I feel like I could reproduce it by extending a NSTextField, but I also feel like it may be something someone else has done before. I've done some searching but have not been able to come up with anything.

Does anyone happen to know where I may find a similar component, or possibly have any suggestions should I attempt it myself?

هل كانت مفيدة؟

المحلول

Thanks to another post, I found ShortcutRecorder. Basically what I was looking for.

نصائح أخرى

Yes samething you can do in the textfield as well:-

  1. You have to make button programmatically inside that set keyEquivalent there.

  2. Set action and target programmatically inside button.

  3. Inside method set your textfield to be becomeFirstResponder. So that whenever user press shortcut your textfield will be selected.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top