0

I am adding Javascript in Vaadin 6 by making a new empty component that only has my JS. Basically I just want to disable Tab key press event on my fields. I searched internet but not found any solution with in vaadin. So I suggested use js to disable Tab key event. The JS that is disabling Tab key is:

$( document ).ready(function() {

    $(".v-absolutelayout-WebFormTable input").keydown(function(event) {

        if (event.keyCode == 9) //tab pressed
        {  
           event.preventDefault(); // stops its action            
        }
    });
});

I am adding the component having the JS on my desired component. On first attempt, it worked as expected. But this solution is not reliable. It donot now works now. Can any one tell me any relaible way to disable tab key press on fields? I just want to disable tab key on only selected fields, not on all of the browser page.

Umair
  • 81
  • 1
  • 1
  • 8

1 Answers1

0

Check out the addShortcutListener method. You can use it to detect that the tab key has been pressed.

Chris M
  • 1,058
  • 1
  • 15
  • 26
  • I cannot use addShortcutListener method because I don't have a fixed number of input fields. I have a layout having many components and they are created on run time by user. Adding addShortcutListener method will require me iterate and find all the Text Fields or inputs fields and add the event handler on all of them. This be too expensive in my case. – Umair Oct 26 '15 at 05:19
  • You can add a shortcut listener to layout, it doesn't have to be added to a field. – Chris M Oct 27 '15 at 19:39
  • I have tied to add this on layout and AbstractLayout. I cannot add it in my case. May be it is because of Vaadin 6? – Umair Nov 03 '15 at 09:46