Browse Source

Change VMenuBar to use KeyDownHandler with Firefox 65+ (#11508)

#11502
tags/7.7.18
Tatu Lund 5 years ago
parent
commit
423f5e0395
1 changed files with 10 additions and 6 deletions
  1. 10
    6
      client/src/main/java/com/vaadin/client/ui/VScrollTable.java

+ 10
- 6
client/src/main/java/com/vaadin/client/ui/VScrollTable.java View File



@Override @Override
public void onKeyPress(KeyPressEvent keyPressEvent) { public void onKeyPress(KeyPressEvent keyPressEvent) {
// This is used for Firefox only, since Firefox auto-repeat
// This is used for Firefox prior to v65 only, since Firefox auto-repeat
// works correctly only if we use a key press handler, other // works correctly only if we use a key press handler, other
// browsers handle it correctly when using a key down handler // browsers handle it correctly when using a key down handler
if (!BrowserInfo.get().isGecko()) {
if (!useOldGeckoNavigation()) {
return; return;
} }


@Override @Override
public void onKeyDown(KeyDownEvent keyDownEvent) { public void onKeyDown(KeyDownEvent keyDownEvent) {
NativeEvent event = keyDownEvent.getNativeEvent(); NativeEvent event = keyDownEvent.getNativeEvent();
// This is not used for Firefox
if (BrowserInfo.get().isGecko()) {
// This is not used for Firefox prior to v65
if (useOldGeckoNavigation()) {
return; return;
} }


scrollBodyPanel.addScrollHandler(this); scrollBodyPanel.addScrollHandler(this);


/* /*
* Firefox auto-repeat works correctly only if we use a key press
* Firefox prior to v65 auto-repeat works correctly only if we use a key press
* handler, other browsers handle it correctly when using a key down * handler, other browsers handle it correctly when using a key down
* handler * handler
*/ */
if (BrowserInfo.get().isGecko()) {
if (useOldGeckoNavigation()) {
scrollBodyPanel.addKeyPressHandler(navKeyPressHandler); scrollBodyPanel.addKeyPressHandler(navKeyPressHandler);
} else { } else {
scrollBodyPanel.addKeyDownHandler(navKeyDownHandler); scrollBodyPanel.addKeyDownHandler(navKeyDownHandler);
updateStyleNames(style, false); updateStyleNames(style, false);
} }


private boolean useOldGeckoNavigation() {
return BrowserInfo.get().isGecko() && BrowserInfo.get().getGeckoVersion() < 65;
}

@Override @Override
public void setStylePrimaryName(String style) { public void setStylePrimaryName(String style) {
updateStyleNames(style, true); updateStyleNames(style, true);

Loading…
Cancel
Save