GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Traversing the table using arrow keys Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Traversing the table using arrow keys" Watch "Traversing the table using arrow keys" New topic
Author

Traversing the table using arrow keys

Swapna Agde
Greenhorn

Joined: Mar 29, 2010
Posts: 6
Hi,
I want to traverse each cell of the table using arrow keys(left, right, up, down). I am able to move the highlighter to each cell as I press the arrow keys.
However I am not able to transfer the focus to each cell. Only the highlighter is moved, but focus remains on the same position where it was initially on page load.
Here is the code snippet:


On page load I am populating the table data in a 2X2 matrix and setting focus to first cell of the table.

However this ".focus" is not working here. Please can anybody tell how to transfer the focus?>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Please read this: UseCodeTags

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Table cells can not be focused. What are trying to accomplish by focusing the cell?

Eric
Swapna Agde
Greenhorn

Joined: Mar 29, 2010
Posts: 6
Sorry for the inconvience caused. I am new to posting help on forums. So kinda got messed up.
Anyway, I am able to focus the cell.
I want to set a focus to the element in the cell i.e button in this case, so that when user hits enter key in particular cell then the desired action is performed.
// for selecting the first cell, I have written following code:




//here curr.focus doesn't work. If I say tabMatrix[0][0].focus then the focus is set to the cell but not the element in the cell.

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Code tags use square brackets [ not angled brackets <

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Your code is



See a problem there?

Eric
Swapna Agde
Greenhorn

Joined: Mar 29, 2010
Posts: 6
Thanks for the reply. I got the problem.
I modified the code as follows:

Now I am able to set a focus to the element in the cell.
Thanks once again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Traversing the table using arrow keys