Skip to main content

Module claim

Module claim 

Source
Expand description

A widget’s own use of the secondary button.

The secondary button opens a context menu everywhere by default, and a canvas may bind a secondary drag in its pointer profile (Blender / node editors pan the graph with it). A widget that needs the right click for something else (a curve editor deleting a point, a swatch resetting its colour, a canvas of its own binding a right drag) claims it on its rect, every pass it is drawn:

use egui_pop_core::pointer::claim::{self, SecondaryClaim};

fn swatch(ui: &mut egui::Ui) {
    let r = ui.allocate_response(egui::vec2(24.0, 24.0), egui::Sense::click());
    claim::claim_secondary(&r, SecondaryClaim::new("Swatch").click("Resets the colour"));
    if r.secondary_clicked() {
        // reset
    }
}

While the pointer was pressed over a claim, neither a context menu opened through context_menu (and egui_pop_api::menus’ context menus) nor a canvas’s profile binding for that gesture fires: the widget alone acts. A claim names the click, the drag or both; a claimed click leaves a secondary drag to the canvas, and the other way round.

A claim lasts the pass it was made in and the next one, so a parent that reads its response before its children are drawn sees them. Claims under a layer drawn above them (a window, a popup) do not count there.

What a claim does, when it says so (a label), is kept as the widget’s use (uses): the shortcuts editor lists the uses seen so far, and the pointer collector of the debug bridge shows them with the claims in force (claims). declare_use lists a use before its widget is first drawn.

Structs§

Claimed
One claim in force.
SecondaryClaim
What a widget takes of the secondary button: the click, the drag, or both, each with what it does there.
WidgetUse
One labelled use seen (or declared): what a widget does with a gesture of the secondary button.

Enums§

Secondary
A gesture of the secondary button a widget can claim.

Functions§

claim_secondary
The widget of response claims the secondary button on its rect for this pass (and the next): see the module.
claim_secondary_rect
As claim_secondary, for a rect of a widget’s (a handle, a point) rather than its whole response.
claimed
The claim of a gesture where the pointer was pressed (where it is, once released): what a canvas or a context menu asks before acting on a secondary click or drag.
claimed_at
The claim of a gesture at a point, if a widget made one there (the last made wins).
claims
The claims in force: made in this pass, or in the last one.
context_menu
egui’s [Response::context_menu], unless a widget claimed the secondary click where it happened: then the menu does not open. The context menu key opens it too while response has the focus, under the widget rather than at the pointer.
context_menu_opened
As context_menu, by_key saying that the keyboard opens it now: for a widget whose rows open menus while the focus stays on the widget (a tree’s cursor row), which asks menu_key itself.
declare_use
Lists a widget’s use of a gesture of the secondary button before the widget is drawn (an application declaring its own canvas’s), for the shortcuts editor.
menu_key
Whether the context menu key was pressed in this pass: Shift+F10, as on Windows, in GTK and Qt, or the Menu key alone. With take, the press is taken out of the input. A widget holding the focus for its rows (a tree, a list) asks this to open its cursor’s menu.
opens_context_menu
Whether response opens its context menu in this pass: a secondary click no widget claimed there, or the context menu key (Shift+F10, or the Menu key) while it has the focus.
report
The claims in force and the uses seen, as the pointer collector shows them.
uses
The uses seen or declared, by widget then gesture.