refactor: add tui.set_focus_by_mouse_event and tui.set_focus_by_widget
This commit is contained in:
parent
ef991a8bee
commit
9e7639e034
1 changed files with 14 additions and 0 deletions
|
|
@ -663,6 +663,20 @@ fn is_live_widget_ptr(self: *Self, w_: *Widget) bool {
|
|||
return if (self.mainview_) |*mv| mv.walk(&ctx, Ctx.find) else false;
|
||||
}
|
||||
|
||||
pub const FocusAction = enum { same, changed, notfound };
|
||||
|
||||
pub fn set_focus_by_widget(w: *Widget) FocusAction {
|
||||
const self = current();
|
||||
const mv = self.mainview_ orelse return .notfound;
|
||||
return mv.focus_view_by_widget(w);
|
||||
}
|
||||
|
||||
pub fn set_focus_by_mouse_event() FocusAction {
|
||||
const self = current();
|
||||
const mv = mainview() orelse return .notfound;
|
||||
return mv.focus_view_by_widget(self.hover_focus orelse return .notfound);
|
||||
}
|
||||
|
||||
fn send_widgets(self: *Self, from: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||
const frame = tracy.initZone(@src(), .{ .name = "tui widgets" });
|
||||
defer frame.deinit();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue