Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for eagerly starting a drag when clicking tab background #80

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading