fix(gui): drop button press events if we also have text input
This commit is contained in:
parent
b1b50b7ff0
commit
6784797078
1 changed files with 13 additions and 4 deletions
|
|
@ -296,6 +296,7 @@ fn wioLoop() void {
|
||||||
|
|
||||||
var held_buttons = input_translate.ButtonSet{};
|
var held_buttons = input_translate.ButtonSet{};
|
||||||
var mouse_pos: wio.Position = .{ .x = 0, .y = 0 };
|
var mouse_pos: wio.Position = .{ .x = 0, .y = 0 };
|
||||||
|
var text_input_active: bool = false;
|
||||||
var running = true;
|
var running = true;
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
|
|
@ -335,14 +336,16 @@ fn wioLoop() void {
|
||||||
}) catch {};
|
}) catch {};
|
||||||
} else {
|
} else {
|
||||||
const cp = input_translate.codepointFromButton(btn, mods);
|
const cp = input_translate.codepointFromButton(btn, mods);
|
||||||
if (cp != 0) sendKey(1, cp, cp, mods);
|
const deferred_to_char = text_input_active and !mods.ctrl and !mods.alt and cp >= 0x20 and cp <= 0x7e;
|
||||||
|
if (cp != 0 and !deferred_to_char) sendKey(1, cp, cp, mods);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.button_repeat => |btn| {
|
.button_repeat => |btn| {
|
||||||
const mods = input_translate.Mods.fromButtons(held_buttons);
|
const mods = input_translate.Mods.fromButtons(held_buttons);
|
||||||
if (input_translate.mouseButtonId(btn) == null) {
|
if (input_translate.mouseButtonId(btn) == null) {
|
||||||
const cp = input_translate.codepointFromButton(btn, mods);
|
const cp = input_translate.codepointFromButton(btn, mods);
|
||||||
if (cp != 0) sendKey(2, cp, cp, mods);
|
const deferred_to_char = text_input_active and !mods.ctrl and !mods.alt and cp >= 0x20 and cp <= 0x7e;
|
||||||
|
if (cp != 0 and !deferred_to_char) sendKey(2, cp, cp, mods);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.button_release => |btn| {
|
.button_release => |btn| {
|
||||||
|
|
@ -391,8 +394,14 @@ fn wioLoop() void {
|
||||||
const row_cell: i32 = @intCast(@divTrunc(@as(i32, @intCast(mouse_pos.y)), wio_font.cell_size.y));
|
const row_cell: i32 = @intCast(@divTrunc(@as(i32, @intCast(mouse_pos.y)), wio_font.cell_size.y));
|
||||||
tui_pid.send(.{ "RDR", "B", @as(u8, 1), btn_id, col_cell, row_cell, @as(i32, 0), @as(i32, 0) }) catch {};
|
tui_pid.send(.{ "RDR", "B", @as(u8, 1), btn_id, col_cell, row_cell, @as(i32, 0), @as(i32, 0) }) catch {};
|
||||||
},
|
},
|
||||||
.focused => window.enableTextInput(.{}),
|
.focused => {
|
||||||
.unfocused => window.disableTextInput(),
|
text_input_active = true;
|
||||||
|
window.enableTextInput(.{});
|
||||||
|
},
|
||||||
|
.unfocused => {
|
||||||
|
text_input_active = false;
|
||||||
|
window.disableTextInput();
|
||||||
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue