Don't open windows when typing into a text field.

fixes #392
This commit is contained in:
IntegratedQuantum 2024-05-26 14:39:35 +02:00
parent ca37eb97d7
commit d99c9ede01
2 changed files with 2 additions and 1 deletions

View File

@ -114,6 +114,7 @@ pub const GLFWCallbacks = struct {
std.log.err("GLFW Error({}): {s}", .{errorCode, description});
}
fn keyCallback(_: ?*c.GLFWwindow, glfw_key: c_int, scancode: c_int, action: c_int, _mods: c_int) callconv(.C) void {
if(main.gui.selectedTextInput != null and c.glfwGetKeyName(glfw_key, scancode) != null) return; // Don't send events for keys that are used in writing letters.
const mods: Key.Modifiers = @bitCast(@as(u6, @intCast(_mods)));
if(action == c.GLFW_PRESS) {
for(&main.KeyBoard.keys) |*key| {

View File

@ -27,7 +27,7 @@ var windowList: List(*GuiWindow) = undefined;
var hudWindows: List(*GuiWindow) = undefined;
pub var openWindows: List(*GuiWindow) = undefined;
var selectedWindow: ?*GuiWindow = null;
var selectedTextInput: ?*TextInput = null;
pub var selectedTextInput: ?*TextInput = null;
var hoveredAWindow: bool = false;
pub var scale: f32 = undefined;