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.
- Secondary
Claim - What a widget takes of the secondary button: the click, the drag, or both, each with what it does there.
- Widget
Use - 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
responseclaims 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 whileresponsehas the focus, under the widget rather than at the pointer. - context_
menu_ opened - As
context_menu,by_keysaying 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 asksmenu_keyitself. - 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
Menukey alone. Withtake, 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
responseopens its context menu in this pass: a secondary click no widget claimed there, or the context menu key (Shift+F10, or theMenukey) while it has the focus. - report
- The claims in force and the uses seen, as the
pointercollector shows them. - uses
- The uses seen or declared, by widget then gesture.