Cocoa Keyboard Shortcuts in Dialog without an Edit Menu

前端 未结 16 1257
Happy的楠姐
Happy的楠姐 2020-12-04 07:28

I have an LSUIElement application that displays a menubar status item. The application can display a dialog window that contains a text field.

If the u

16条回答
  •  时光取名叫无心
    2020-12-04 07:38

    No need to add a new class, extension or really any code at all.

    1. Just add a new MenuItems in one of your menus and name them 'Copy', 'Cut' and 'Paste'.
    2. Add the correct shortcut keys to each item.
    3. Control+drag to connect them up to the corresponding methods listed under first responder.

    The bonus here is that the items are not hidden from your users, and this takes less time that creating a new class and reassigning all of your existing TextFields to it.

提交回复
热议问题