fix(terminal): focus switching
This commit is contained in:
parent
aff2a7919b
commit
330d2b1f66
3 changed files with 7 additions and 1 deletions
|
|
@ -7479,7 +7479,7 @@ pub const EditorWidget = struct {
|
|||
|
||||
fn mouse_click_event(self: *Self, event: input.Event, btn: input.Mouse, y: c_int, x: c_int, ypx: c_int, xpx: c_int) Result {
|
||||
if (event != input.event.press) return;
|
||||
if (!self.focused) switch (btn) {
|
||||
if (!self.focused or tui.is_keyboard_focused()) switch (btn) {
|
||||
input.mouse.BUTTON1, input.mouse.BUTTON2, input.mouse.BUTTON3 => _ = tui.set_focus_by_mouse_event(),
|
||||
else => {},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1825,6 +1825,7 @@ pub fn focus_view_by_widget(self: *Self, w: Widget) tui.FocusAction {
|
|||
}
|
||||
|
||||
pub fn focus_view(self: *Self, n: usize) !void {
|
||||
tui.clear_keyboard_focus();
|
||||
if (n == self.active_view) return;
|
||||
if (n > self.views.widgets.items.len) return;
|
||||
if (n == self.views.widgets.items.len)
|
||||
|
|
|
|||
|
|
@ -852,6 +852,11 @@ pub fn set_focus_by_mouse_event() FocusAction {
|
|||
return .changed;
|
||||
}
|
||||
|
||||
pub fn is_keyboard_focused() bool {
|
||||
const self = current();
|
||||
return self.keyboard_focus != null;
|
||||
}
|
||||
|
||||
pub fn set_keyboard_focus(w: Widget) void {
|
||||
const self = current();
|
||||
if (self.keyboard_focus) |prev| prev.unfocus();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue