diff --git a/hyperlap2d-common-api b/hyperlap2d-common-api index b0cca697..7179e2b1 160000 --- a/hyperlap2d-common-api +++ b/hyperlap2d-common-api @@ -1 +1 @@ -Subproject commit b0cca697ccccef0fcb6122ae7b876a415611b650 +Subproject commit 7179e2b1878837b1fa54970e8bd05e2c64e59792 diff --git a/src/main/java/games/rednblack/editor/event/KeyboardListener.java b/src/main/java/games/rednblack/editor/event/KeyboardListener.java index 43bbaf92..635ada7e 100644 --- a/src/main/java/games/rednblack/editor/event/KeyboardListener.java +++ b/src/main/java/games/rednblack/editor/event/KeyboardListener.java @@ -32,19 +32,26 @@ import games.rednblack.editor.HyperLap2DFacade; public class KeyboardListener implements EventListener { private final String eventName; + private final boolean handleFocus; private String lastValue; public KeyboardListener(String eventName) { + this(eventName, true); + } + + public KeyboardListener(String eventName, boolean focus) { this.eventName = eventName; + this.handleFocus = focus; } @Override public boolean handle(Event event) { - if (event instanceof FocusListener.FocusEvent) { + if (handleFocus && event instanceof FocusListener.FocusEvent) { handleFocusListener((FocusListener.FocusEvent) event); return true; } + if (event instanceof InputEvent) { handleInputListener((InputEvent) event); return true; @@ -57,8 +64,6 @@ public class KeyboardListener implements EventListener { case keyUp: if (event.getKeyCode() == Input.Keys.ENTER || event.getKeyCode() == Input.Keys.NUMPAD_ENTER) { keyboardHandler((VisTextField) event.getTarget()); - VisTextField field = (VisTextField) event.getTarget(); - lastValue = field.getText(); } break; } @@ -68,9 +73,9 @@ public class KeyboardListener implements EventListener { VisTextField field = (VisTextField) event.getTarget(); if(event.isFocused()) { //it was a focus in event, which is no change - lastValue = field.getText(); return; } + switch (event.getType()) { case keyboard: keyboardHandler(field); @@ -78,19 +83,21 @@ public class KeyboardListener implements EventListener { case scroll: break; } - } private void keyboardHandler(VisTextField target) { if(!target.isInputValid()) { return; } + // check for change - if(lastValue.equals(target.getText())) { + if(lastValue != null && lastValue.equals(target.getText())) { // no change = no event; return; } + lastValue = target.getText(); + HyperLap2DFacade facade = HyperLap2DFacade.getInstance(); facade.sendNotification(eventName, target.getText()); } diff --git a/src/main/java/games/rednblack/editor/view/stage/SandboxMediator.java b/src/main/java/games/rednblack/editor/view/stage/SandboxMediator.java index 1b2836cf..cb5e864e 100644 --- a/src/main/java/games/rednblack/editor/view/stage/SandboxMediator.java +++ b/src/main/java/games/rednblack/editor/view/stage/SandboxMediator.java @@ -27,6 +27,7 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.SnapshotArray; +import com.kotcrab.vis.ui.FocusManager; import games.rednblack.editor.utils.KeyBindingsLayout; import games.rednblack.h2d.common.MsgAPI; import games.rednblack.h2d.common.view.tools.Tool; @@ -199,6 +200,8 @@ public class SandboxMediator extends Mediator { public boolean touchDown(Entity entity, float x, float y, int pointer, int button) { super.touchDown(entity, x, y, pointer, button); + setSandboxFocus(); + switch (button) { case Input.Buttons.MIDDLE: // if middle button is pressed - PAN the scene @@ -372,13 +375,7 @@ public class SandboxMediator extends Mediator { public boolean touchDown(Entity entity, float x, float y, int pointer, int button) { super.touchDown(entity, x, y, pointer, button); - Sandbox sandbox = Sandbox.getInstance(); - - // setting key and scroll focus on main area - sandbox.getUIStage().setKeyboardFocus(); - sandbox.getUIStage().setScrollFocus(sandbox.getUIStage().midUI); - sandbox.setKeyboardFocus(); - + setSandboxFocus(); switch (button) { case Input.Buttons.MIDDLE: @@ -491,4 +488,14 @@ public class SandboxMediator extends Mediator { public String getCurrentSelectedToolName() { return currentSelectedTool != null ? currentSelectedTool.getName() : ""; } + + private void setSandboxFocus() { + Sandbox sandbox = Sandbox.getInstance(); + FocusManager.resetFocus(sandbox.getUIStage()); + + // setting key and scroll focus on main area + sandbox.getUIStage().setKeyboardFocus(); + sandbox.getUIStage().setScrollFocus(sandbox.getUIStage().midUI); + sandbox.setKeyboardFocus(); + } } diff --git a/src/main/java/games/rednblack/editor/view/ui/box/UIMultiPropertyBox.java b/src/main/java/games/rednblack/editor/view/ui/box/UIMultiPropertyBox.java index 5f82ede7..917e6be3 100644 --- a/src/main/java/games/rednblack/editor/view/ui/box/UIMultiPropertyBox.java +++ b/src/main/java/games/rednblack/editor/view/ui/box/UIMultiPropertyBox.java @@ -39,7 +39,6 @@ public class UIMultiPropertyBox extends UICollapsibleBox { propertiesTable = new VisTable(); scrollPaneInner = new VisTable(); scrollPane = StandardWidgetsFactory.createScrollPane(scrollPaneInner); - scrollPane.setFadeScrollBars(true); propertiesTable.add(scrollPane).maxHeight(Gdx.graphics.getHeight() * 0.38f).width(BOX_DEFAULT_WIDTH); diff --git a/src/main/java/games/rednblack/editor/view/ui/properties/UIItemCollapsibleProperties.java b/src/main/java/games/rednblack/editor/view/ui/properties/UIItemCollapsibleProperties.java index 20a1b129..30f972c6 100644 --- a/src/main/java/games/rednblack/editor/view/ui/properties/UIItemCollapsibleProperties.java +++ b/src/main/java/games/rednblack/editor/view/ui/properties/UIItemCollapsibleProperties.java @@ -39,7 +39,6 @@ public abstract class UIItemCollapsibleProperties extends UIItemProperties { public UIItemCollapsibleProperties(String title) { this.title = title; - mainTable = new VisTable(); row().padTop(9).padBottom(6); add(crateHeaderTable()).expandX().fillX().padBottom(7); createCollapsibleWidget(); diff --git a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIBasicItemPropertiesMediator.java b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIBasicItemPropertiesMediator.java index 2defb0c9..27d58bb8 100644 --- a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIBasicItemPropertiesMediator.java +++ b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIBasicItemPropertiesMediator.java @@ -150,6 +150,22 @@ public class UIBasicItemPropertiesMediator extends UIItemPropertiesMediator