DVUI

tabIndexSetEx

Parameters

#
widget_id:Id
Id
tab_index:?u16
?u16
rect:?Rect.Physical
?Rect.Physical
tab_group:bool
bool

Source

Implementation

#
pub fn tabIndexSetEx(widget_id: Id, tab_index: ?u16, rect: ?Rect.Physical, tab_group: bool) void {
    if (tab_index != null and tab_index.? == 0)
        return;

    var cw = currentWindow();
    var ti = TabIndex{
        .windowId = cw.subwindows.current_id,
        .widgetId = widget_id,
        .pt = if (rect) |r| r.topLeft() else .{},
        .tab_index_group = TabIndexGroup.current,
        .tabIndex = (tab_index orelse math.maxInt(u16)),
        .tab_group = tab_group,
    };

    if (cw.subwindows.get(cw.subwindows.current_id)) |sw| {
        if (sw.focus_group) |fg| {
            fg.tab_index.append(cw.arena(), ti) catch |err| {
                logError(@src(), err, "Could not set focus group tab index.", .{});
            };

            // now modify the TabIndex so that we can look it up in the global order
            ti.in_focus_group = true;
            ti.tabIndex = fg.data().options.tab_index orelse math.maxInt(u16);
        }
    }

    cw.tab_index.append(cw.gpa, ti) catch |err| {
        logError(@src(), err, "Could not set tab index.", .{});
    };
}