Double use of widget ID with context menu on draggable area
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
Describe the bug
I have an Area that is moveable by dragging it, and has a context menu. As soon as it's moved from the starting position, I get a big "Double use of widget ID" warning. This might very well be me doing something wrong, but I don't see what or how I can avoid it. The ID it's complaining about is not the ID of the area, but the ID of the response.
To Reproduce
use eframe::egui::{self, Area, Color32, Frame, Id, Pos2, Vec2};
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
..Default::default()
};
let mut pos = Pos2::new(40., 40.);
eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
egui::CentralPanel::default().show(ctx, |ui| {
let area = Area::new(Id::new("area"));
let area_response = area.current_pos(pos).show(ui.ctx(), |ui| {
let frame = Frame::default().fill(Color32::from_rgb(70, 70, 70)); // The frame is just to see better, it's not necessary to reproduce the problem
frame.show(ui, |ui| {
ui.allocate_space(Vec2::new(100., 100.));
});
});
if area_response.response.dragged() {
let delta = ui.ctx().input(|i| i.pointer.delta());
pos[0] += delta.x;
pos[1] += delta.y;
}
area_response.response.context_menu(|_ui| {});
});
})
}
Click and drag the gray area a bit.
Expected behavior
No warning.
Screenshots
Desktop (please complete the following information):
OS: Linux. Reproduced under egui 2dac4a4f (current master).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Rust reproduction in the issue body and tracing the interaction between Area::show, the draggable response, and response.context_menu. Inspect where the “Double use of widget ID” warning is emitted and add a regression test for moving an Area with a context menu; done means the reproduction no longer warns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100