link
A label that calls openURL when clicked.
Parameters
- src:std.builtin.SourceLocation
- std.builtin.SourceLocation
- init_opts:LinkOptions
- LinkOptions
- opts:Options
- Options
Source
Implementation
pub fn link(src: std.builtin.SourceLocation, init_opts: LinkOptions, opts: Options) void {
const defaults: Options = .{ .color_text = dvui.themeGet().focus, .font = dvui.Font.theme(.body).withUnderline(.{}) };
var click_event: dvui.Event.EventTypes = undefined;
if (dvui.labelClick(src, "{s}", .{init_opts.label orelse init_opts.url}, .{ .click_event = &click_event }, defaults.override(opts))) {
const new_window = (click_event == .mouse and (click_event.mouse.button == .middle or click_event.mouse.mod.matchBind("ctrl/cmd")));
_ = dvui.openURL(.{ .url = init_opts.url, .new_window = new_window });
}
}