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;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Key;
import com.vaadin.flow.component.KeyModifier;
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
*/
public ControlPanel(ControlPanelView view) {
public ControlPanel(ControlPanelView view, Component focusArea) {
firstStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT), evt -> view.firstStepButton());
lastStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_RIGHT), evt -> view.lastStepButton());
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());
// todo change shortcut scope
firstStep.addClickShortcut(Key.ARROW_LEFT, KeyModifier.CONTROL);
lastStep.addClickShortcut(Key.ARROW_RIGHT, KeyModifier.CONTROL);
nextStep.addClickShortcut(Key.ARROW_RIGHT);
previousStep.addClickShortcut(Key.ARROW_LEFT);
firstStep.addClickShortcut(Key.ARROW_LEFT, KeyModifier.CONTROL).listenOn(focusArea);
lastStep.addClickShortcut(Key.ARROW_RIGHT, KeyModifier.CONTROL).listenOn(focusArea);
nextStep.addClickShortcut(Key.ARROW_RIGHT).listenOn(focusArea);
previousStep.addClickShortcut(Key.ARROW_LEFT).listenOn(focusArea);
add(share, firstStep, previousStep, nextStep, lastStep);
}

View File

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

View File

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

View File

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