Hyperlink
hyperlink · Elements · interactive
A hyperlink.
Import
cpp
#include "gbui/widgets/hyperlink.hpp"Example
cpp
[[nodiscard]] bool hyperlink(Ui& ui, const Interaction& input, std::string_view id, std::string_view label, const HyperlinkOptions& options = {});Returns true on the frame it was followed — by click, or by Return while focused. hyperlink rather than link, because link in a C++ codebase already means the linker, a linked list, or the act of linking; this is the one thing it does not usually mean.
API
HyperlinkOptions
| Option | Type | Default | What it does |
|---|---|---|---|
href | std::string_view | Where it points. Following it hands this to openUrl. Empty follows nothing and only reports the click, which is what a link that scrolls somewhere inside the application wants. | |
chord | Modifiers | Modifiers that must be held for a click to count. All false — the default — means a plain click follows it, which is what a link is. Requiring a chord is for a link inside editable text, where a plain click has to place the caret instead; that is the bargain every editor makes, and it is a decision about the surrounding document rather than about the link, so it is the caller's. | |
disabled | bool | false | |
trailing optional | std::optional<Icon> | Drawn after the label — an arrow for "this leaves the application". | |
color | Token | Token::Accent | |
size | float | kAuto | |
underlineOnHover | bool | false | Underlines always, or only under the pointer. Always is the accessible default: colour alone is not a cue for anyone who cannot see it. |