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

[Enhancement]: Drawing outside of the window #521

Closed
1 task done
vi opened this issue Nov 1, 2023 · 20 comments
Closed
1 task done

[Enhancement]: Drawing outside of the window #521

vi opened this issue Nov 1, 2023 · 20 comments
Assignees
Labels
enhancement Small enhancements to existing features good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@vi
Copy link

vi commented Nov 1, 2023

What happened?

It thinks that input device keeps touching and interprets further clicks as double touches.

bottombug.webm

Version

2.0.0-beta.14

Platform

Web

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@vi vi added the bug Something isn't working label Nov 1, 2023
@CodeDoctorDE
Copy link
Member

Seems like the pointer up event doesn't fire if you go out of the window and release the input device.
I will investigate how I can fix this

@CodeDoctorDE
Copy link
Member

I tested it myself but couldn't replicate it anymore.
Which browser do you use on which operating system?

@vi
Copy link
Author

vi commented Nov 8, 2023

Firefox 115.3.0esr on Linux Debian with i3 on Xorg, with a number of extensions installed and user-chrome.css snippets active.

Trying on a clean Firefox profile: the bug is still reproducible.
Trying on a clean Chromium profile: not reproducible.
Trying on Fennec (Firefox for Android): not reproducible.

@CodeDoctorDE
Copy link
Member

Yeah, chromium works fine on me.
The problem is that I don't get a PointerUp event if the window is unfocused: https://dartpad.dev/?id=21592fa42e503eb99da3cabd804c18fb
I currently see no solution how to fix it.

@CodeDoctorDE
Copy link
Member

Fixed in 2.0.0-beta.15, if you refresh the website, it should be fixed

@CodeDoctorDE CodeDoctorDE added this to the 2.0 milestone Nov 8, 2023
@vi
Copy link
Author

vi commented Nov 8, 2023

Still reproducible on https://preview.butterfly.linwood.dev/ . Settings show 15'th revision.

@CodeDoctorDE CodeDoctorDE reopened this Nov 8, 2023
@CodeDoctorDE
Copy link
Member

Oh, I will look at it again...

@CodeDoctorDE
Copy link
Member

Okay, it should now reset all inputs when unfocused. Can you test if the bug appears in the current version? (don't forget to refresh the site after loading so that it can fetch the newest version)

@vi
Copy link
Author

vi commented Nov 8, 2023

Behaviour changed now: it does not lock to zoom mode. Stroke being drawn gets frozen until I click again, it cancels the stroke entirely.

disappear.webm

Better than before (I can continue using the app instead of being forced to reload the window and maybe lose unsaved content), but still suboptimal. User should not "be afraid of the edges". Not sure how to attain it though. Maybe some heuristics?

@CodeDoctorDE
Copy link
Member

CodeDoctorDE commented Nov 8, 2023

Oh you are right. Thanks for testing, i will try to fix this

@CodeDoctorDE
Copy link
Member

I think now it should be fixed

@vi
Copy link
Author

vi commented Nov 8, 2023

Now it does not erase the stroke, but also does not continue after cursor is offscreen.

It should work like in e.g. https://sketch.io/sketchpad/ - in the same Firefox I can continue drawing a stroke even when cursor is off the browser window. It also explicitly reacts to mouse button release even when cursor is away.

sketchio.webm

Can Butterfly work the same way?

@CodeDoctorDE
Copy link
Member

The problem is I can't get the pointer id that leaves the app, and if you release the device when outside of the app, I don't get this event.
I think we can keep this for now. The bug is fixed.

@vi
Copy link
Author

vi commented Nov 9, 2023

if you release the device when outside of the app, I don't get this event

Why sketch.io does receive a mouse up event even when cursor is away from Firefox window, as demonstrated on the video?

pointer id

If there is only one pointer (i.e. mouse, no multi-touch) then any mouse release is the pointer release.

@CodeDoctorDE
Copy link
Member

Okay...
I researched a bit and found out you need to capture the input. I will try it out now and notify you if I found a solution.

https://stackoverflow.com/questions/14407869/capture-mouseup-event-outside-of-browser-window

@CodeDoctorDE
Copy link
Member

Okay I tried everything but couldn't find a solution. setPointerCapture(event.pointerId) does not work when listing on them.
I will mark this as good first issue Good for newcomers if anyone wants to help me fixing this.

@CodeDoctorDE CodeDoctorDE added the good first issue Good for newcomers label Nov 9, 2023
@CodeDoctorDE CodeDoctorDE removed this from the 2.0 milestone Nov 9, 2023
@CodeDoctorDE CodeDoctorDE changed the title [Bug]: Drawing too low locks UI into zoom mode [Enhancement]: Drawing outside of the window Nov 9, 2023
@CodeDoctorDE CodeDoctorDE added enhancement Small enhancements to existing features help wanted Extra attention is needed and removed bug Something isn't working confirmed labels Nov 9, 2023
@MrGumpIT
Copy link
Contributor

What is the drawing area widget? Where is it located in the code? Could you try to identify its dimensions and deactivate the pen when it reaches there without having to read the id

@CodeDoctorDE
Copy link
Member

CodeDoctorDE commented Feb 1, 2024

Hi,
thanks for your interest.
The drawaing area widget is this:

CustomPaint(
size: Size.infinite,
foregroundPainter: ForegroundPainter(
cubit.getForegrounds(),
state.data,
state.page,
state.info,
Theme.of(context).colorScheme,
transform,
cubit.state.selection,
currentIndex.cameraViewport.utilities,
),
painter: ViewPainter(
state.data,
state.page,
state.info,
cameraViewport:
currentIndex.cameraViewport,
transform: transform,
invisibleLayers: state.invisibleLayers,
states: currentIndex.allRendererStates,
currentArea: state.currentArea,
colorScheme:
Theme.of(context).colorScheme,
),
isComplex: true,
willChange: true,
)
.

I intentionally disabled this feature:

onExit: kIsWeb
? (event) => cubit.resetInput(
context.read<DocumentBloc>())
: null,
.
The problem is that I don't get a pointerup event to unregister the input and otherwise you will end up zooming with one input because the other input wasn't unregistered.

You can try it out if you remove the onExit callback and start the webserver with flutter run -d web-server and connect with firefox to this url

@MrGumpIT
Copy link
Contributor

Can this work for you?

Recording.2024-03-20.101314.mp4

@CodeDoctorDE
Copy link
Member

Fixed in 2.1.0-beta.4 thanks to @MrGumpIT in #646

@CodeDoctorDE CodeDoctorDE added this to the 2.1 milestone Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Small enhancements to existing features good first issue Good for newcomers help wanted Extra attention is needed
Projects
Archived in project
Development

No branches or pull requests

3 participants