• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextfields and keyboard equivalents - am I missing something?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextfields and keyboard equivalents - am I missing something?


  • Subject: Re: NSTextfields and keyboard equivalents - am I missing something?
  • From: John Stiles <email@hidden>
  • Date: Mon, 21 Apr 2008 10:05:11 -0700

In "The Path Of Key Events" in the URL you posted, the #1 item in the list is "key equivalents."
AppKit checks keyDown events to see if command is held; if it is, it tries to match it against the menus before passing it through the responder chain.
I think your best bet is to dim your menu item or remove its key equivalent when a text field gains first responder, and then restore it when the text field loses first responder.


Mattias Arrelid wrote:
I have a simple test application with a few custom menu items. Let's
assume that _none_ of these items has a key equivalent of COMMAND +
(right arrow) for now.

When the first responder of the application is an NSTextField, and the
user produces COMMAND + (right arrow), the insertion point is being
placed right after the last character in the text field. This is true
as long as the text field stays the first responder. As mentioned
earler, I _don't_ have a menu item with such a key equivalent at this
point.

If I add a menu item that _has_ a key equivalent of COMMAND + (righ
arrow), what happens is that this item's action is performed when I
press the above key combo - even if the text field is the first
responder. Is this supposed to happen? When reading the Cocoa
Event-Handling documentation, I stumbled upon this:

http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/chapter_2_section_3.html#//apple_ref/doc/uid/10000060i-CH3-SW10

Inspired by that, I enabled some breakpoints in my project. From
these, I can see that the text field doesn't seem to care about saying
"yes, I do respond to COMMAND + (right arrow)" when its
"performKeyEquivalent:" is called, which explains why the menu item
gets the action eventually. Is this correct?

To sum things up: I want the text field to respond to all "standard"
key equivalents (move cursor to front, end, move word forward/backward
etc.), even if I have a menu item with such a key equivalent. There
are applications that behave like this, e.g. iTunes, and I do think
that this is the correct behavior. Could anyone point me in the right
direction here?

Regards
Mattias
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTextfields and keyboard equivalents - am I missing something?
      • From: "Mattias Arrelid" <email@hidden>
References: 
 >NSTextfields and keyboard equivalents - am I missing something? (From: "Mattias Arrelid" <email@hidden>)

  • Prev by Date: Consistent Contextual Menu in NSTableview
  • Next by Date: Re: Implementing a Slightly Unusual NSTableView
  • Previous by thread: NSTextfields and keyboard equivalents - am I missing something?
  • Next by thread: Re: NSTextfields and keyboard equivalents - am I missing something?
  • Index(es):
    • Date
    • Thread