wow, my first contribution to a real/active open source project, thanks!
I did that also yesterday at school, almost the same :D
tableView.getComponentKeyListeners().add(new ComponentKeyListener() {
public boolean keyTyped(Component component, char character) {
return false;
}
public boolean keyPressed(Component component, int keyCode,
KeyLocation keyLocation) {
if (keyCode == KeyCode.ENTER) {
if(!tableViewRowEditor.isEditing())
tableViewRowEditor.edit(tableView,
tableView.getSelectedIndex(), 0);
}
return true;
}
public boolean keyReleased(Component component, int keyCode,
KeyLocation keyLocation) {
return false;
}
});
Right now I'm thinking about multiple-select, then TableView has
getSelectedRanges and getSelectedRows. So I was gonna suggest to add
getSelectedIndices. <- but maybe later for this, I still have a lot to do
for my project. For now I'll just register for the 'del' key for shortcut.
btw, what's the return boolean value for? in the pivot code I saw
// no-op
return false;
thanks again
-
thirdy/vicente
On Fri, Sep 18, 2009 at 9:44 AM, Todd Volkert <[email protected]> wrote:
> I just applied the patch - nicely done! :)
>>
>> I'd also like to add a keylistener so that when a user presses Enter, the
>> current row will enter into edit-mode. Where can I code for that?
>
> That probably belongs at the application level, but it'd look something
like
> this...
> tableView.getComponentKeyListeners().add(new
ComponentKeyListener.Adapter()
> {
> @Override
> public boolean keyPressed(Component component, int keyCode,
> Keyboard.KeyLocation keyLocation) {
> if (keyCode == Keyboard.KeyCode.ENTER) {
> tableView.getRowEditor().editRow(tableView,
> tableView.getSelectedIndex(), 0);
> }
> }
> });
>