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

Add TableBuilder::drag_to_scroll #3100

Merged
merged 2 commits into from
Aug 14, 2023

Conversation

KYovchevski
Copy link
Contributor

Closes #3097

@vvv
Copy link
Contributor

vvv commented Jun 26, 2023

@KYovchevski If I understand #3097 correctly, you want to be able to set drag_to_scroll = false.

ScrollArea gets the default behavior, which is drag_to_scroll = true, but I may not want that behavior.

I gave TableBuilder::drag_to_scroll a try, but failed to notice any difference from the default behaviour.

I ran 3 versions of the demo app (cargo run -p egui_demo_app --release):

  1. master (9478e50)
  2. your branch (e8865d1)
  3. your branch with the patch below
diff --git a/crates/egui_demo_lib/src/demo/table_demo.rs b/crates/egui_demo_lib/src/demo/table_demo.rs
index 8fdea420..ceeadf4a 100644
--- a/crates/egui_demo_lib/src/demo/table_demo.rs
+++ b/crates/egui_demo_lib/src/demo/table_demo.rs
@@ -127,6 +127,7 @@ impl TableDemo {
         let mut table = TableBuilder::new(ui)
             .striped(self.striped)
             .resizable(self.resizable)
+            .drag_to_scroll(false)
             .cell_layout(egui::Layout::left_to_right(egui::Align::Center))
             .column(Column::auto())
             .column(Column::initial(100.0).range(40.0..=300.0))

I failed to notice any difference between the cases — I was always able to scroll the table by dragging its body:

2023-06-26.23-34-12.mp4

@KYovchevski What is the desired effect?

@KYovchevski
Copy link
Contributor Author

@vvv The desired effect is to expose the body's underlying ScrollArea's drag_to_scroll option by adding a builder function that allows it to be set and passed down to the ScrollArea

I just tested on both master and my branch with the patch you provided, and the behaviour is as intended:

  • On master, the table can be scrolled by dragging on it with the mouse, and this fact cannot be changed.
  • On my branch, running with .drag_to_scroll(false) causes the dragging on the table body to not scroll it. I also tested the same property with true, which results in the same behaviour as master.

@vvv
Copy link
Contributor

vvv commented Jun 27, 2023

@KYovchevski Ah, I understand why it didn't work for me! I used “two fingers scrolling” gesture on MacBook's trackpad. That is equivalent to scrolling with mouse's wheel. It is not the same as dragging.

When I use a mouse or click-and-drag properly with a trackpad, the PR works as intended.

Sorry for the noise.

@emilk
Copy link
Owner

emilk commented Aug 9, 2023

I'm not sure why the CI isn't kicking in. Perhaps try merging in latest master and see if it helps?

@emilk emilk merged commit 043183a into emilk:master Aug 14, 2023
19 checks passed
@tosti007 tosti007 deleted the table-drag-to-scroll branch August 16, 2023 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add drag_to_scroll to scroll options of the table
3 participants