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

Secondary click on mobile #865

Closed
mankinskin opened this issue Nov 1, 2021 · 3 comments · Fixed by #4195
Closed

Secondary click on mobile #865

mankinskin opened this issue Nov 1, 2021 · 3 comments · Fixed by #4195
Labels
design Some architectual design work needed

Comments

@mankinskin
Copy link
Contributor

mankinskin commented Nov 1, 2021

Recently, context menus got added, but they can't be used on mobile because there is no way to perform a secondary click.

Usually, a long tap is interpreted as a secondary click. The default context menu may not be suitable for mobile, because it is too small, but being able to trigger it with the same code as on desktop is a first step for bringing this feature.

@mankinskin
Copy link
Contributor Author

This may collide with the long tap from #501 .. This is also a problem on desktop web, where the native context menu is overridden because egui catches the mouse events. But I am unsure if this is really circumventable, because not all platforms have a native context menu, so I guess the best egui can do is try to create a native context menu when asked to and if one exists. This could allow us to use native context menus on mobile.

@emilk emilk added the design Some architectual design work needed label Nov 1, 2021
@emilk
Copy link
Owner

emilk commented Nov 1, 2021

It's unclear how to best implement this.

Should egui_web interpret any long-press touch as a secondary mouse click? Or should egui do so, using the touch events it receives? What happens when one wants to drag something?

Anyone wants to try experimenting with this?

@mankinskin
Copy link
Contributor Author

I wanted to try to implement this some time, but I can't say when I want to start yet.. most probably a drag event will only be created when the pointer moves out of a fixed radius or something similar. Might do some research about how this is usually implemented.

Another thing is that the distinction between mouse click and touch screen touch seems to sometimes disappear in egui.. I am not sure but we might need to make that more clear to prevent secondary clicks being triggered when holding the left mouse button down. In other words, the long tap should not apply for left mouse button clicks.

emilk added a commit that referenced this issue Mar 20, 2024
* Closes #3444
* Closes #865

On a touch screen, if you press down on a widget and hold for 0.6
seconds (`MAX_CLICK_DURATION`), it will now trigger a secondary click,
i.e. `Response::secondary_clicked` will be `true`. This means you can
now open context menus on touch screens.
hacknus pushed a commit to hacknus/egui that referenced this issue Oct 30, 2024
* Closes emilk#3444
* Closes emilk#865

On a touch screen, if you press down on a widget and hold for 0.6
seconds (`MAX_CLICK_DURATION`), it will now trigger a secondary click,
i.e. `Response::secondary_clicked` will be `true`. This means you can
now open context menus on touch screens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Some architectual design work needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants