Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Keyboard Navigation "Tab" #267

Open
duckwilliamson opened this issue Aug 28, 2012 · 9 comments
Open

Feature Request: Keyboard Navigation "Tab" #267

duckwilliamson opened this issue Aug 28, 2012 · 9 comments

Comments

@duckwilliamson
Copy link

I have no idea even where to begin with this, or I'd implement a potential patch. It would be very useful if, maybe using the Keyboard Mixin, we could hit Tab and go to the next cell for editing. Has anyone considered this before? Is it possible?

@kurtinatlanta
Copy link

Yes, it's possible.

On Aug 27, 2012, at 23:28, duckwilliamson [email protected] wrote:

I have no idea even where to begin with this, or I'd implement a potential patch. It would be very useful if, maybe using the Keyboard Mixin, we could hit Tab and go to the next cell for editing. Has anyone considered this before? Is it possible?


Reply to this email directly or view it on GitHub.

@phated
Copy link

phated commented Mar 13, 2013

Using dgrid 0.3.6, this worked for me: set your editOn value to 'dgrid-cellfocusin' and then bind keydown on the grid, as such

on(grid, 'keydown', function(e){
    if(e.keyCode === keys.TAB){
      Keyboard.moveFocusRight.call(grid, e);
    }
});

@kfranqueiro
Copy link
Member

Indeed; you could also potentially do something like:

grid.addKeyHandler(keys.TAB, Keyboard.moveFocusRight);

This works since handlers registered via addKeyHandler are always executed in the context of the instance, and are passed the event. Though I'd point out that also registering shift+tab to move left would take more work (and might run into shenanigans when combined with Selection since it'd think you're highlighting a range).

@oracast-benhaigh
Copy link

Hmm I get an error Keyboard.moveFocusRight is not defined?

@kfranqueiro
Copy link
Member

Are you working with dgrid 0.3.6? As noted by @phated, that's when this was added.

@frabe
Copy link

frabe commented Mar 14, 2013

Is it also possible to have the

Keyboard.moveFocusLeft

on a key-combination like SHIFT+TAB (for Excel style navigation) ?

@kfranqueiro
Copy link
Member

As I mentioned in my previous response, that should be feasible, though it'd require more work since you'd need to actually write a function to call Keyboard.moveFocusLeft or Keyboard.moveFocusRight depending on whether event.shiftKey is true, and if you're using the Selection mixin, you may need to work around the fact that it will assume that shift held during a dgrid-cellfocusin event means to select a range.

@phated
Copy link

phated commented Mar 21, 2013

It seems grid.addKeyHandler(keys.TAB, Keyboard.moveFocusRight); doesn't work on an editable cell while editing, else I am doing something wrong. If that is the case, I will have to stick with my example.

@stdavis
Copy link

stdavis commented May 29, 2013

@phated: Your example worked well for me using and editable cell. Thanks!

It also easily supports the SHIFT+TAB request by @frabe with a minor mod:

on(this.grid, 'keydown', function (e) {
    if (e.keyCode === keys.TAB) {
        if (!e.shiftKey) {
            Keyboard.moveFocusRight.call(that.grid, e);
        } else {
            Keyboard.moveFocusLeft.call(that.grid, e);
        }
    }
});

@duckwilliamson: You may want to close this issue to help keep things cleaned up. This solution seems to me to be a good answer. But maybe I'm missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants