• 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: NSTableView Always Undesirably Selects First Row when It Loses Key Focus
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView Always Undesirably Selects First Row when It Loses Key Focus


  • Subject: Re: NSTableView Always Undesirably Selects First Row when It Loses Key Focus
  • From: Grant Erickson <email@hidden>
  • Date: Mon, 26 Oct 2009 17:08:47 -0700
  • Thread-topic: NSTableView Always Undesirably Selects First Row when It Loses Key Focus

On 10/23/09 4:31 PM, Grant Erickson wrote:
> I have a device list in my preference pane implemented as a NSTableView under
> 10.5, not unlike the list of network devices in Apple's Network preference
> pane.
>
> Unlike the Network table, in my case there is no mandate that an item (i.e.
> row) always be selected. However, if there are no rows selected, when I hit
> the tab key to change the key focus from my table to the preferences search
> field, the table automatically, yet undesirably, selects the first row.
>
> Is this standard, albeit undocumented, NSTableView behavior? If so, what is
> the best way to prevent this from happening? Is one of the should*Select*
> delegate methods most appropriate?

It was suggested off-list to set breakpoints on a few of the table delegate
methods. I get two calls to selectionShouldChangeInTableView, one to
shouldSelectRow and one to tableViewSelectionDidChange.

The curiosity seems to be why NSTableView keyDown, when receiving <Tab> and
losing key focus, insists on "selecting the next focused cell" when there is
no currently focused cell and the overall table is, in fact, losing focus.

> #0    -[MyPreferencePane selectionShouldChangeInTableView:]
> #1    -[NSTableView _userCanChangeSelection]
> #2    -[NSTableView _selectNextFocusedCellGoingForward:andEdit:]
> #3    -[NSTableView keyDown:]
> #4    -[NSWindow sendEvent:]
> #5    -[NSApplication sendEvent:]
> #6    ??
> #7    -[NSApplication run]
> #8    NSApplicationMain
> #9    ??
>
> #0    -[MyPreferencePane selectionShouldChangeInTableView:]
> #1    -[NSTableView _userCanChangeSelection]
> #2    -[NSTableView
> _userSelectableRowIndexesForProposedSelection:userCanAlreadyChangeSelection:]
> #3    -[NSTableView _userSelectableRowIndexesForProposedSelection:]
> #4    -[NSTableView _userCanSelectRow:withNewSelectedIndexes:]
> #5    -[NSTableView
> _findFirstUserSelectableRowStartingFrom:to:selectedRowsOkay:byExtendingSelecti
> on:]
> #6    -[NSTableView _selectNextFocusedCellGoingForward:andEdit:]
> #7    -[NSTableView keyDown:]
> #8    -[NSWindow sendEvent:]
> #9    -[NSApplication sendEvent:]
> #10   ??
> #11   -[NSApplication run]
> #12   NSApplicationMain
> #13   ??
>
> #0    -[MyPreferencePane tableView:shouldSelectRow:]
> #1    -[NSTableView _sendDelegateCanSelectRow:]
> #2    -[NSTableView _oldUserCanSelectRow:]
> #3    -[NSTableView
> _userSelectableRowIndexesForProposedSelection:userCanAlreadyChangeSelection:]
> #4    -[NSTableView _userSelectableRowIndexesForProposedSelection:]
> #5    -[NSTableView _userCanSelectRow:withNewSelectedIndexes:]
> #6    -[NSTableView
> _findFirstUserSelectableRowStartingFrom:to:selectedRowsOkay:byExtendingSelecti
> on:]
> #7    -[NSTableView _selectNextFocusedCellGoingForward:andEdit:]
> #8    -[NSTableView keyDown:]
> #9    -[NSWindow sendEvent:]
> #10   -[NSApplication sendEvent:]
> #11   ??
> #12   -[NSApplication run]
> #13   NSApplicationMain
> #14   ??
>
> #0    -[MyPreferencePane tableViewSelectionDidChange:]
> #1    _nsnote_callback
> #2    __CFXNotificationPost
> #3    _CFXNotificationPostNotification
> #4    -[NSNotificationCenter postNotificationName:object:userInfo:]
> #5    -[NSNotificationCenter postNotificationName:object:]
> #6    -[NSTableView _enableSelectionPostingAndPost]
> #7    -[NSTableView selectRowIndexes:byExtendingSelection:]
> #8    -[NSTableView _selectNextFocusedCellGoingForward:andEdit:]
> #9    -[NSTableView keyDown:]
> #10   -[NSWindow sendEvent:]
> #11   -[NSApplication sendEvent:]
> #12   ??
> #13   -[NSApplication run]
> #14   NSApplicationMain
> #15   ??
>
FWIW, the NSOutlineView in the Desktop and Screen Saver preference pane
exhibits this same behavior.

Command-click whatever current saver you have selected to deselect it and
then hit <Tab> to get to the preference search box. The outline view will
auto-select whatever saver shows up in the first expanded grouping.

-Grant

_______________________________________________

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: NSTableView Always Undesirably Selects First Row when It Loses Key Focus
      • From: Grant Erickson <email@hidden>
References: 
 >NSTableView Always Undesirably Selects First Row when It Loses Key Focus (From: Grant Erickson <email@hidden>)

  • Prev by Date: Re: Moving from standalone apps to some internet related programming
  • Next by Date: Re: Moving from standalone apps to some internet related programming
  • Previous by thread: Re: NSTableView Always Undesirably Selects First Row when It Loses Key Focus
  • Next by thread: Re: NSTableView Always Undesirably Selects First Row when It Loses Key Focus
  • Index(es):
    • Date
    • Thread