Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Send PointerSignalKind.scale events from web#36348

Merged
auto-submit[bot] merged 3 commits into
flutter-team-archive:mainfrom
moffatman:web_scale
Mar 20, 2023
Merged

Send PointerSignalKind.scale events from web#36348
auto-submit[bot] merged 3 commits into
flutter-team-archive:mainfrom
moffatman:web_scale

Conversation

@moffatman

Copy link
Copy Markdown
Contributor

Send PointerSignalKind.scale instead of PointerSignalKind.scroll if ctrl key is pressed on wheel event.

Part of flutter/flutter#112103

Sequence

  1. ui.PointerSignalKind forwards compatibility for scale flutter/flutter#112170
  2. Add discrete scale pointer signal #36342
  3. Add PointerScaleEvent and use in InteractiveViewer flutter/flutter#112172
  4. This PR

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to make sure this is customizable at the app-level if possible, otherwise looks fine to me.

CC @mdebbar Another one that could use a backup review from a web person, thank you!

scrollDeltaX: deltaX,
scrollDeltaY: deltaY,
);
if (event.ctrlKey) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens on Mac with ctrl and cmd?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctrlKey is just how the browser sends scroll events, for legacy reasons. It's still called ctrlKey on the mac. In my mac Chrome, neither seem to cause a zoom if i hold them and scroll.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wheel events with ctrlKey on Mac do not zoom/scale. Instead they just scroll. But with this PR, the scrolling will stop, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that ctrl (not cmd) and scroll will continue to do the same thing (scroll) after this PR, is that right @moffatman?

scrollDeltaY: deltaY,
);
if (event.ctrlKey) {
_pointerDataConverter.convert(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could decide what combination of key + scroll does what at the framework level, in case some developers have different opinions about that. Is that something that we could make possible? I get that we need to prevent the browser from zooming in at the engine level though.

Comment on lines +362 to +370
}
else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be } else {.

@moffatman

Copy link
Copy Markdown
Contributor Author

To clarify, right now we are ignoring these ctrl-zoom events altogether. So this isn't causing things that would scroll before to now cause zooms.

@mdebbar

mdebbar commented Sep 27, 2022

Copy link
Copy Markdown
Contributor

@moffatman you are right that we ignore ctrl-zoom now, but that's not the case on Mac/iOS.

@moffatman

Copy link
Copy Markdown
Contributor Author

@mdebbar So on macOS, when using ctrl-scroll wheel, what's the expected behavior?

@mdebbar

mdebbar commented Oct 6, 2022

Copy link
Copy Markdown
Contributor

@moffatman I believe on macOS, it should just scroll even if ctrl is pressed.

@moffatman

Copy link
Copy Markdown
Contributor Author

@mdebbar I noticed sites which offer trackpad gestures (Ex: Figma) do not handle that properly, they will zoom-in if holding ctrl and scrolling. I guess the only option is to watch document onkey events and have a parallel tracking of the real ctrlKey. Do you think that's worth doing?

@mdebbar

mdebbar commented Oct 6, 2022

Copy link
Copy Markdown
Contributor

@moffatman I think, by default, we should do what the platform does (in this case, browsers on macOS scroll even if ctrl is pressed).

Apps can customize this behavior if they want to. I'm not sure if they can do such customization today with Flutter or not. Thoughts @justinmc ?

@justinmc

justinmc commented Oct 6, 2022

Copy link
Copy Markdown
Contributor

Right now I don't believe there's a straightforward way to override a keyboard shortcut and a mouse gesture combined.

@Renzo-Olivares would that be possible with your upcoming gesture shortcuts work?

@skia-gold

Copy link
Copy Markdown

Gold has detected about 8 new digest(s) on patchset 3.
View them at https://flutter-engine-gold.skia.org/cl/github/36348

@Piinks

Piinks commented Nov 22, 2022

Copy link
Copy Markdown
Contributor

Right now I don't believe there's a straightforward way to override a keyboard shortcut and a mouse gesture combined.

I asked @gspencergoog about this recently, I was looking into shift+scroll to flip the scroll direction. He recommended not tying it into shortcuts, but just checking the keyboard when a scroll event comes in. So I have a proposal out that would add that key modifier on the inherited ScrollBehavior. Maybe something similar would suit here for ctrl?
flutter/flutter#115610

@goderbauer

Copy link
Copy Markdown
Contributor

@moffatman @justinmc @mdebbar @Piinks Are there still plans for this PR? It is getting a little stale...

@moffatman

Copy link
Copy Markdown
Contributor Author

Remaining issues

  • Is there something that should be done here for future compatibility with framework-defined modifier keys
    • I'm not so sure here, it doesn't make sense as the events are different types
  • Using the mouse wheel while holding ctrl is not supposed to zoom on macOS, just scroll.
    • macOS scroll+zooms and trackpad pinches will both have event.ctrlKey, so we can't tell them apart from the event alone. Will need to add some sort of tracking of key-presses in order to tell if it's a true ctrlKey or not.

To start with, I will fix the merge conflicts at least..

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

I'm on board with moving forward with this PR as-is. It seems to me like we're matching browser behavior as close as practical right now. If we do decide that we want to support scaling with other keys, we'll have to rethink our event signalKinds and maybe come up with some combined event that includes both scrolling and scaling. That's probably beyond the scope of this PR.

scrollDeltaX: deltaX,
scrollDeltaY: deltaY,
);
if (event.ctrlKey) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that ctrl (not cmd) and scroll will continue to do the same thing (scroll) after this PR, is that right @moffatman?

@moffatman

moffatman commented Mar 16, 2023

Copy link
Copy Markdown
Contributor Author

I still need to add some sort of tracking for the ctrl key press. Since right now it will zoom instead of scroll on macOS safari.

@moffatman

Copy link
Copy Markdown
Contributor Author

Would appreciate some review from anyone involved in web keyboard handling. I made some very lazy changes to expose what I needed to peek at the data. Maybe there is a better way?

@mdebbar mdebbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the kPhysicalControlRight oversight, this PR looks good to me!

Comment thread lib/web_ui/lib/src/engine/pointer_binding.dart Outdated
@Piinks

Piinks commented Mar 17, 2023

Copy link
Copy Markdown
Contributor

Looks like there are some merge conflicts FYI

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App embedder Related to the embedder API platform-web Code specifically for the web engine

Development

Successfully merging this pull request may close these issues.

7 participants