Issue with Shortcut delete

Hi,

I have an issue with the vaadin shortcut delete. Pressing the
shortcut

delete key
should clear the value of the vaadin component. It works fine with
IE10 browser
but the same code is not working with
google chrome browser
. Could you please help me to resolve this issue?


I used the following code for shortcut delete (component - ComboBox) :

comboBox.addFocusListener(new FocusListener() {

    @Override
    public void focus(FocusEvent event) {
      comboBox.addShortcutListener(shortcutListener);
    }
  });
  comboBox.addBlurListener(new BlurListener() {

    @Override
    public void blur(BlurEvent event) {
      comboBox.removeShortcutListener(shortcutListener);
    }
  });
  comboBox.setImmediate(true);

When I debugged the code in IE, the below are sequence of events occurred while adding and removing the shortcut key Listener

  1. When the control gets a Focus, we are adding a Shortcutkey listener ---- ( FocusEvent is fired)

  2. When the Delete key is pressed, it clears the Combo Box value — [ com.xybion.kk.controls.ComboBoxControl.ComboBoxControl(…).new ShortcutListener() {…}.handleAction(Object, Object) is getting called and which has the logic to clear values ]

  3. When we exit out of the Combo Box, the Delete shortcut key will be unregistered. [Blur event is fired-- where the Delete Shortcutkey is unregistered]

When I debugged the code in Chrome, the below are sequence of events occurred while adding and removing the shortcut key Listener

  1. When the control gets a Focus, we are adding a Shortcutkey listener ---- ( FocusEvent is fired)
  2. When the Delete key is pressed, — [ Here the Blur Event is getting fired instead of calling – com.xybion.kk.controls.ComboBoxControl.ComboBoxControl(…).new ShortcutListener() {…}.handleAction(Object, Object) ]
    , since in the com.xybion.kk.controls.ComboBoxControl.ComboBoxControl(…).new BlurListener() {…}.blur(BlurEvent) we are removing the Shortcut key listener the Shourtcut implementation for Delete Key was never got called]

*** NOTE: if I comment the line comboBox.removeShortcutListener(shortcutListener); then the code works fine in Chrome this tells that clearly the blur event should not be called until we exit from the control, but this is not a workaround and this is not a fix.

Please help me on this such that the code should work browser independent.

Hi Thamizh,

maybe I’m too simple now and not getting the full idea - but: isn’t it an option to track whether you’re inside the control and invoke the shortcut listener depending on that (i.e. on Focus set inside=true; in the ShortcutLIstener return unless inside==true and in on Blur set inside=false)?

Just from the top of my head - but maybe it helps

Best Regards
Sebastian