Don't handle keybinds when a popup or text input is open

This commit is contained in:
Moulberry committed 2024-08-25 05:36:38 +08:00
1 parent 08e8d3df29
commit 6579039ba8
1 file changed
+12 -1
@@ -438,11 +438,13 @@ public class TimelineWindow {
} }
} }
boolean shouldProcessInput = !ImGui.isPopupOpen("", ImGuiPopupFlags.AnyPopup) && !ImGui.getIO().getWantTextInput();
if (shouldProcessInput) {
handleKeyPresses(replayServer, cursorTicks, editorState, totalTicks); handleKeyPresses(replayServer, cursorTicks, editorState, totalTicks);
boolean leftClicked = ImGui.isMouseClicked(ImGuiMouseButton.Left); boolean leftClicked = ImGui.isMouseClicked(ImGuiMouseButton.Left);
boolean rightClicked = ImGui.isMouseClicked(ImGuiMouseButton.Right); boolean rightClicked = ImGui.isMouseClicked(ImGuiMouseButton.Right);
if ((leftClicked || rightClicked) && !ImGui.isPopupOpen("", ImGuiPopupFlags.AnyPopup)) { if (leftClicked || rightClicked) {
handleClick(editorState, replayServer, totalTicks); handleClick(editorState, replayServer, totalTicks);
} else if (ImGui.isMouseDragging(ImGuiMouseButton.Left)) { } else if (ImGui.isMouseDragging(ImGuiMouseButton.Left)) {
if (grabbedExportBarResizeLeft) { if (grabbedExportBarResizeLeft) {
@@ -493,6 +495,9 @@ public class TimelineWindow {
} else if (!ImGui.isAnyMouseDown()) { } else if (!ImGui.isAnyMouseDown()) {
releaseGrabbed(editorState, replayServer, totalTicks); releaseGrabbed(editorState, replayServer, totalTicks);
} }
} else {
releaseGrabbed(editorState, replayServer, totalTicks);
}
} }
ImGui.end(); ImGui.end();
} }
@@ -1080,6 +1085,12 @@ public class TimelineWindow {
grabbedKeyframe = false; grabbedKeyframe = false;
} }
if (pendingStepBackwardsTicks > 0 && !ImGui.isKeyDown(GLFW.GLFW_KEY_LEFT)) {
replayServer.goToReplayTick(Math.max(0, replayServer.getReplayTick() - pendingStepBackwardsTicks));
replayServer.forceApplyKeyframes.set(true);
pendingStepBackwardsTicks = 0;
}
} }
record GrabMovementInfo(int grabbedDelta, int grabbedScalePivotTick, float grabbedScaleFactor) {} record GrabMovementInfo(int grabbedDelta, int grabbedScalePivotTick, float grabbedScaleFactor) {}