╭ changed ────────╮ │src/ui/widget.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │129 pub fn clickOnSelectedRow(list: *wgt.Box(Widget), root_focus: *Focus, mouse: xitui.input.Mouse) bool { │ │130 const cid = list.getFocus().child_id orelse return false; │ │131 return inp.leftClickOn(root_focus, cid, mouse); │ │132 +} │ │133 + │ │134 +// a detail pane's way back to a list that isn't shown beside it. it leads the │ │135 +// pane's frame, above the pane's content, hidden while the list shows. │ │136 +const list_back_index = 0; │ │137 +pub const list_pane_index = 1; │ │138 + │ │139 +pub fn addListBack(allocator: std.mem.Allocator, frame: *wgt.Box(Widget), label: []const u8) !void { │ │140 + var back = try wgt.TextBox.init(allocator, label, .{ .border = .single, .round_corners = true, .wrap_kind = .none }); │ │141 + errdefer back.deinit(allocator); │ │142 + back.getFocus().mode = .all; │ │143 + try frame.children.put(allocator, back.getFocus().id, .{ .widget = .{ .text_box = back }, .rect = null, .min_size = null, .hidden = true });│ │144 +} │ │145 + │ │146 +// point the way back at the shown list row's in-page link, so both hosts hand │ │147 +// its press and enter to the view instead of navigating │ │148 +pub fn setListBackLink(frame: *wgt.Box(Widget), link: []const u8) void { │ │149 + frame.children.values()[list_back_index].widget.text_box.getFocus().kind = .{ .custom = link }; │ │150 +} │ │151 + │ │152 +pub fn showListBack(frame: *wgt.Box(Widget), shown: bool) void { │ │153 + frame.children.values()[list_back_index].hidden = !shown; │ │154 + if (!shown and frame.getFocus().child_id == frame.children.keys()[list_back_index]) │ │155 + frame.getFocus().child_id = frame.children.keys()[list_pane_index]; │ │156 +} │ │157 + │ │158 +// the way back's focus id while it shows │ │159 +pub fn listBackId(frame: *wgt.Box(Widget)) ?usize { │ │160 + return if (frame.children.values()[list_back_index].hidden) null else frame.children.keys()[list_back_index]; │ │161 } │ │162 │ │163 +// enter the pane on the way back. selecting it (then focusing the frame) also │ │164 +// handles the too-narrow case where the pane isn't laid out yet. │ │165 +pub fn focusListBack(frame: *wgt.Box(Widget), root_focus: *Focus) void { │ │166 + frame.getFocus().child_id = frame.children.keys()[list_back_index]; │ │167 + root_focus.setFocus(frame.getFocus().id); │ │168 +} │ │169 + │ │170 pub const back_button_width = 3; │ │171 const back_button_height = 3; │ │172 const back_kind = "back"; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯