Fix invalid key event handling in GLFWInput | make GUI does not extend KeyEventHandler interface anymore
This commit is contained in:
@@ -3,7 +3,6 @@ package com.bartlomiejpluta.base.engine.gui.render;
|
||||
import com.bartlomiejpluta.base.api.camera.Camera;
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.*;
|
||||
import com.bartlomiejpluta.base.api.input.KeyEvent;
|
||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
import com.bartlomiejpluta.base.engine.error.AppException;
|
||||
import com.bartlomiejpluta.base.engine.gui.manager.FontManager;
|
||||
@@ -418,11 +417,6 @@ public class NanoVGGUI implements GUI {
|
||||
nvgResetScissor(nvg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleKeyEvent(KeyEvent event) {
|
||||
screenWidget.handleKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
log.info("Disposing GUI color buffers");
|
||||
|
||||
@@ -234,7 +234,7 @@ public class ScreenWidget implements Widget {
|
||||
|
||||
@Override
|
||||
public void handleKeyEvent(KeyEvent event) {
|
||||
root.handleKeyEvent(event);
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ public class GLFWInput implements Input {
|
||||
this.windowHandle = screen.getID();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ForLoopReplaceableByForEach")
|
||||
public GLFWInput init() {
|
||||
log.info("Registering key callback");
|
||||
glfwSetKeyCallback(windowHandle, (window, key, scancode, action, mods) -> {
|
||||
@@ -34,7 +33,8 @@ public class GLFWInput implements Input {
|
||||
}
|
||||
|
||||
// Use iterator to support removal from loop inside
|
||||
for (var iterator = keyEventHandlers.iterator(); iterator.hasNext(); ) {
|
||||
// We need also to iterate in FILO order (a stack-based model)
|
||||
for (var iterator = keyEventHandlers.descendingIterator(); iterator.hasNext(); ) {
|
||||
if (event.isConsumed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user