Skip to main content

Module hover_card

Module hover_card 

Source
Expand description

Rich hover cards: the tier between a tooltip and a popover. A card opens after the hover delay on a widget, stays open while the pointer moves onto it (so its links can be clicked), and closes on leave after a short grace, on Escape or on a click elsewhere.

Experimental: may change in any release (docs/stability.md).

Its content is data (Card): formatted text (a small Markdown subset: **bold**, `code`, - list lines), rows of key and value, progress, separators and command links. Being data, an agent reads it without hovering (Card::plain_text, or the card serialised), and the same card is the widget’s accessible description. Live values come for free: the owner builds the card each pass from its state.

HoverCard::show draws it next to any widget (a status item, a toolbar button, a row, a port) and returns the link clicked, which the owner runs (an egui-pop App runs a command with its when and its steps, as anywhere else). open opens one from the keyboard: the focus then goes to its first link, and Tab moves through them.

use egui_pop_core::hover_card::{Card, HoverCard};
use egui_pop_model::ids::CommandId;

fn vault(ui: &mut egui::Ui, images: u32) {
    let r = ui.button("Vault");
    let card = Card::new()
        .text("**Vault** is open")
        .row("Images", images.to_string())
        .row("Last import", "07:12")
        .separator()
        .link("Show imports", CommandId::from_static("vault.imports"), serde_json::Value::Null);
    if let Some(link) = HoverCard::new("vault").show(ui, &r, &card) {
        let _ = link.command; // run it
    }
}

Structs§

Card
What a hover card shows.
HoverCard
A hover card next to a widget.
Line
A line of formatted text.
Link
A link in a card: a command run with its arguments.
Row
One row of a card’s key and value table.

Enums§

Block
A part of a card, top to bottom.
Span
A run of text in a line, by style.

Functions§

close
Closes a card.
is_open
Whether a card is open.
lines
Formatted text’s lines: - starts a list item, **…** is bold, `…` is code (no formatting inside); a mark left open is kept as text.
open
Opens a card from the keyboard (or for an agent): it stays open until Escape or a click elsewhere, and its first link takes the focus.
paint
Draws a card’s content; the link clicked. focus gives the first link the keyboard focus.
spans
A line’s spans.