Limit area of key listeners

This commit is contained in:
Arne Keller 2021-02-01 15:16:04 +01:00
parent 9c8edf2e07
commit 9d7a16cc86
4 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package edu.kit.typicalc.view.content; package edu.kit.typicalc.view.content;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Key; import com.vaadin.flow.component.Key;
import com.vaadin.flow.component.KeyModifier; import com.vaadin.flow.component.KeyModifier;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
@ -23,7 +24,7 @@ public class ControlPanel extends HorizontalLayout {
* *
* @param view the view that reacts to the button clicks * @param view the view that reacts to the button clicks
*/ */
public ControlPanel(ControlPanelView view) { public ControlPanel(ControlPanelView view, Component focusArea) {
firstStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT), evt -> view.firstStepButton()); firstStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT), evt -> view.firstStepButton());
lastStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_RIGHT), evt -> view.lastStepButton()); lastStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_RIGHT), evt -> view.lastStepButton());
nextStep = new Button(new Icon(VaadinIcon.ANGLE_RIGHT), evt -> view.nextStepButton()); nextStep = new Button(new Icon(VaadinIcon.ANGLE_RIGHT), evt -> view.nextStepButton());
@ -31,10 +32,10 @@ public class ControlPanel extends HorizontalLayout {
share = new Button(new Icon(VaadinIcon.CONNECT), evt -> view.shareButton()); share = new Button(new Icon(VaadinIcon.CONNECT), evt -> view.shareButton());
// todo change shortcut scope // todo change shortcut scope
firstStep.addClickShortcut(Key.ARROW_LEFT, KeyModifier.CONTROL); firstStep.addClickShortcut(Key.ARROW_LEFT, KeyModifier.CONTROL).listenOn(focusArea);
lastStep.addClickShortcut(Key.ARROW_RIGHT, KeyModifier.CONTROL); lastStep.addClickShortcut(Key.ARROW_RIGHT, KeyModifier.CONTROL).listenOn(focusArea);
nextStep.addClickShortcut(Key.ARROW_RIGHT); nextStep.addClickShortcut(Key.ARROW_RIGHT).listenOn(focusArea);
previousStep.addClickShortcut(Key.ARROW_LEFT); previousStep.addClickShortcut(Key.ARROW_LEFT).listenOn(focusArea);
add(share, firstStep, previousStep, nextStep, lastStep); add(share, firstStep, previousStep, nextStep, lastStep);
} }

View File

@ -28,7 +28,7 @@ public class StartPageView extends VerticalLayout implements ControlPanelView {
setId("start-page"); setId("start-page");
setSizeFull(); setSizeFull();
content = new Div(); content = new Div();
controlPanel = new ControlPanel(this); controlPanel = new ControlPanel(this, this);
Scroller scroller = new Scroller(content); Scroller scroller = new Scroller(content);
scroller.setSizeFull(); scroller.setSizeFull();
scroller.setScrollDirection(Scroller.ScrollDirection.BOTH); scroller.setScrollDirection(Scroller.ScrollDirection.BOTH);

View File

@ -31,7 +31,7 @@ public class TypeInferenceView extends VerticalLayout
setSizeFull(); setSizeFull();
addAttachListener(this); addAttachListener(this);
content = new Div(); content = new Div();
controlPanel = new ControlPanel(this); controlPanel = new ControlPanel(this, this);
Scroller scroller = new Scroller(content); Scroller scroller = new Scroller(content);
scroller.setSizeFull(); scroller.setSizeFull();
scroller.setScrollDirection(Scroller.ScrollDirection.BOTH); scroller.setScrollDirection(Scroller.ScrollDirection.BOTH);

View File

@ -78,7 +78,6 @@ public class TypeAssumptionParserTest {
new FunctionType(BOOLEAN, BOOLEAN) new FunctionType(BOOLEAN, BOOLEAN)
), ),
Collections.emptyList()), assumption.getValue()); Collections.emptyList()), assumption.getValue());
System.err.println("new type");
parser = new TypeAssumptionParser(); parser = new TypeAssumptionParser();
type = parser.parse("id", "((int -> int) -> (boolean -> boolean)) -> ((int2 -> boolean2) -> (boolean2 -> int2))"); type = parser.parse("id", "((int -> int) -> (boolean -> boolean)) -> ((int2 -> boolean2) -> (boolean2 -> int2))");
if (type.isError()) { if (type.isError()) {