Skip to content

Commit

Permalink
Don't open windows when typing into a text field.
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegratedQuantum committed May 26, 2024
1 parent ca37eb9 commit d99c9ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/graphics/Window.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/gui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d99c9ed

Please sign in to comment.