DVUI

labelClick

A clickable label. See link. Returns true if it's been clicked.

Parameters

#
src:std.builtin.SourceLocation
std.builtin.SourceLocation
fmt:[]const u8
[]const u8
args:anytype
anytype
init_opts:LabelClickOptions
LabelClickOptions
opts:Options
Options

Source

Implementation

#
pub fn labelClick(src: std.builtin.SourceLocation, comptime fmt: []const u8, args: anytype, init_opts: LabelClickOptions, opts: Options) bool {
    const defaults: Options = .{ .name = "LabelClick", .role = .link };
    var lw: LabelWidget = undefined;
    lw.init(src, fmt, args, init_opts.label_opts, defaults.override(opts));
    // draw border and background

    dvui.tabIndexSet(lw.data().id, lw.data().options.tab_index, lw.data().rectScale().r);

    var ret = false;
    if (dvui.clickedEx(lw.data(), .{ .buttons = .any })) |click_event| {
        ret = true;
        if (init_opts.click_event) |ce| ce.* = click_event;
    }

    // draw text
    lw.draw();

    // draw an accent border if we are focused
    if (lw.data().id == dvui.focusedWidgetId()) {
        lw.data().focusBorder();
    }

    if (lw.data().accesskit_node()) |ak_node| {
        AccessKit.nodeAddAction(ak_node, AccessKit.Action.click);
    }

    // done with lw, have it report min size to parent
    lw.deinit();

    return ret;
}