Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Traversing the table using arrow keys

 
Swapna Agde
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this: UseCodeTags

Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Table cells can not be focused. What are trying to accomplish by focusing the cell?

Eric
 
Swapna Agde
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code tags use square brackets [ not angled brackets <

Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code is



See a problem there?

Eric
 
Swapna Agde
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic