Skip to content

Commit

Permalink
Remove unnecessary context menu from drag-and-drop example
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 25, 2024
1 parent 86aaa05 commit 4d164ce
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions crates/egui_demo_lib/src/demo/drag_and_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,7 @@ impl super::View for DragAndDropDemo {
for (row_idx, item) in column.iter().enumerate() {
let item_id = Id::new(id_source).with(col_idx).with(row_idx);
let response = drag_source(ui, item_id, |ui| {
let response = ui.add(Label::new(item).sense(Sense::click()));
response.context_menu(|ui| {
if ui.button("Remove").clicked() {
self.columns[col_idx].remove(row_idx);
ui.close_menu();
}
});
ui.add(Label::new(item).sense(Sense::click()));
});

if response.drag_started() {
Expand All @@ -151,13 +145,6 @@ impl super::View for DragAndDropDemo {
})
.response;

let response = response.context_menu(|ui| {
if ui.button("New Item").clicked() {
self.columns[col_idx].push("New Item".to_owned());
ui.close_menu();
}
});

// NOTE: we use `response.contains_pointer` here instead of `hovered`, because
// `hovered` is always false when another widget is being dragged.
if response.contains_pointer() && ui.input(|i| i.pointer.any_released()) {
Expand Down

0 comments on commit 4d164ce

Please sign in to comment.