Re: Grabbing key presses in NSTableView
Re: Grabbing key presses in NSTableView
- Subject: Re: Grabbing key presses in NSTableView
- From: Bill Cheeseman <email@hidden>
- Date: Tue, 27 Apr 2004 15:29:52 -0400
on 2004-04-27 1:46 PM, Stiphane Sudre at email@hidden wrote:
>
I think the subclass solution is better for the following reasons:
>
>
1) You don't have to have a delete button even visible or invisible.
>
And you don't need to disable it when there is no selection.
>
>
2) You don't have to set the delete key equivalent to the delete menu
>
item which does not conform to the HIG. And one point you're forgetting
>
is that the delete item needs to be disabled when there is no selection.
1) I think I understand your item 1. If you don't want a Delete Row button
in your interface, then my button-with-key-equivalent technique would be
inconsistent with the design. I agree.
However, if you do want a button (or a menu item) to delete a table row --
as I normally do -- then my technique is pretty natural. Disabling the
button (or menu item) when no row is selected is then a desirable and
obvious part of the design -- and I've always found it easy to code.
2) As to your item 2, I think what you're saying -- correct me if I'm wrong
-- is that the HIG prescribes no key equivalent for the Edit menu's Delete
item, so assigning the Delete key to it would be inconsistent with the HIG.
But I didn't mean to suggest using the Edit menu's Delete item to delete a
table row -- I think users tend to associate the Delete menu item with text
editing, for the most part, so I try to avoid it for deleting other kinds of
objects. There's no conflict with the HIG if you assign the Delete key to
some other menu item meant specially for deletion of table rows, which is
what I had in mind. (As far as I can tell, the HIG does not forbid use of
Command-Delete as a key equivalent for an appropriate menu item.)
I actually wasn't focusing on the use of the Delete key in particular,
anyway -- I only meant to address the issue of an easy technique to make any
desired keystroke trigger deletion of a row.
Personally, I like to put this kind of table view functionality in a
separate Table (or Outline) menu where I collect commands relating to
manipulation of the table (or outline). This is especially useful with
outline views, where menu items and key equivalents to indent and outdent,
etc., are commonly placed in a separate menu devoted to that purpose. If I
assign keystrokes at all, I try to use a set of keystrokes that is somewhat
meaningful, like Command-arrow keys and Command-minus or Command-plus.
(Then, of course, I have to turn to the HIG to see if I've chosen key
equivalents that Apple has already taken over -- and these days that's just
about all of them!)
So, bottom line, if you want a button and/or a menu item for deleting table
view rows, it's real easy to assign any keystroke to either the button or
the menu item, and you don't need to subclass NSTableView.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.