Skip to content

Commit

Permalink
Fix for eagerly starting a drag when clicking tab background (#80)
Browse files Browse the repository at this point in the history
* Closes #79
  • Loading branch information
emilk authored Aug 27, 2024
1 parent 1be4183 commit 3f182e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Pane {
let color = egui::epaint::Hsva::new(0.103 * self.nr as f32, 0.5, 0.5, 1.0);
ui.painter().rect_filled(ui.max_rect(), 0.0, color);
let dragged = ui
.allocate_rect(ui.max_rect(), egui::Sense::drag())
.allocate_rect(ui.max_rect(), egui::Sense::click_and_drag())
.on_hover_cursor(egui::CursorIcon::Grab)
.dragged();
if dragged {
Expand Down
10 changes: 4 additions & 6 deletions src/container/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,11 @@ impl Tabs {

let output = scroll_area.show(ui, |ui| {
if !tree.is_root(tile_id) {
// Make the background behind the buttons draggable (to drag the parent container tile):
// Make the background behind the buttons draggable (to drag the parent container tile).
// We also sense clicks to avoid eager-dragging on mouse-down.
let sense = egui::Sense::click_and_drag();
if ui
.interact(
ui.max_rect(),
ui.id().with("background"),
egui::Sense::drag(),
)
.interact(ui.max_rect(), ui.id().with("background"), sense)
.on_hover_cursor(egui::CursorIcon::Grab)
.drag_started()
{
Expand Down

0 comments on commit 3f182e0

Please sign in to comment.