• 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: Deselect keyboard focus of an NSMatrix cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deselect keyboard focus of an NSMatrix cell


  • Subject: Re: Deselect keyboard focus of an NSMatrix cell
  • From: Kyle Sluder <email@hidden>
  • Date: Thu, 22 Jul 2010 13:26:28 -0700

On Thu, Jul 22, 2010 at 11:05 AM, Jochen Moeller <email@hidden> wrote:
> Greetings,
>
> I want to be able to deselect the keyboard focus of a control after hitting Return, whereas Tab moves to the nextKeyView.

This is accomplished by the field editor. See the documentation for
-[NSText isFieldEditor].

>
> When using editable NSTextField objects I can achieve this in the action method with:
>    [ window makeFirstResponder:[ window contentView ]];
>
> But when using editable NSTextFieldCell objects in an NSMatrix I found no way to do that.
> The -makeFirstResponder: method seems not to respond.

-makeFirstResponder: returns a BOOL. See the documentation for
-[NSWindow endEditingFor:] for what to do when -makeFirstResponder:
returns NO.

>
> I tried this:
> 1. Same as above.
>
> 2. Additional a custom content view which returned YES for
>    -acceptsFirstResponder and -canBecomeKeyView.
>
> 3. Additional modifying the NSMatrix object: "matrix" is the outlet.
>    [ matrix setAllowsEmptySelection:YES ];
>    NSLog(@"selectedCell: %p", [matrix selectedCell]); // a valid pointer
>    [ matrix deselectAllCells ];
>    NSLog(@"selectedCell: %p", [matrix selectedCell]); // 0x0, but the focus ring remains, why ?

Because the matrix is still the first responder?

>    [ matrix display ]; // the focus ring remains
>    [ window makeFirstResponder:[ window contentView ]]; // did not work.
>    // Also [ window makeFirstResponder:anotherTextField ]; did not work.
>
> The key focus still remains in the textfield cell of the matrix.
>
> Any ideas?

Do you have a custom formatter or a binding set up on the matrix that
might cause validation to fail and the field editor to refuse to
resign first responder status? To see if it's the field editor
refusing to resign first responder, return a custom NSTextView
subclass from -windowWillReturnFieldEditor:toObject: that simply
overrides -resignFirstResponder to call through to super, and break on
that return statement to see if the field editor's implementation is
returning NO.

--Kyle Sluder
_______________________________________________

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: Deselect keyboard focus of an NSMatrix cell
      • From: Jochen Moeller <email@hidden>
References: 
 >Deselect keyboard focus of an NSMatrix cell (From: Jochen Moeller <email@hidden>)

  • Prev by Date: Re: Array controllers in code?
  • Next by Date: Re: print object by %@
  • Previous by thread: Deselect keyboard focus of an NSMatrix cell
  • Next by thread: Re: Deselect keyboard focus of an NSMatrix cell
  • Index(es):
    • Date
    • Thread