atlas-engineer / nyxt

Nyxt - the hacker's browser.
https://nyxt-browser.com/
9.91k stars 415 forks source link

[Feature request] Enable text selection with long press on touch screens #1170

Open Kabouik opened 3 years ago

Kabouik commented 3 years ago

In addition to visual mode and regular selection with the cursor, it would be great if Nyxt allowed selecting text with a long press. This would make Nyxt usable on devices with touch screen (tablets, touch laptops, mobile Linux devices like Pinephone, Pro1, PlanetCo, UMPCs, etc.) when no mouse is connected.

Firefox has this feature, not only on mobile but also on the desktop application:

Screenshot_20210223_001

I don't remember if this is required or if this just enables touch scrolling. I also don't know if that is a Firefox feature or related to the engine itself.

Sorry if that is already possible. I asked on IRC some weeks ago and was under the impression that opening an issue would be relevant.

Ambrevar commented 3 years ago

If WebKitGTK can do it, then it should be no problem! Unfortunately I don't have any device to test this.

Kabouik commented 3 years ago

Happy to help if I can, but I won't be able to write any common-lisp code by myself I'm afraid. Webkit should support it, see screenshot below showing text selection in Epiphany (right):

Screenshot_20210223_002

Probably a browser toggle somewhere because Luakit doesn't allow it, at least not as default (left):

Screenshot_20210223_003

Kabouik commented 2 years ago

Actually the browser on the right in the above screenshots is Chromium, not Epiphany. I was confused because they're both just called "Web" in rofi, and I'm not used to Chromium anyway so I didn't recognize the UI. I can't long press to select in Epiphany either, and same in Vimb and Luakit. Now that doesn't necessarily mean that Webkit can't do it, but right now long press just shows the context menu.

jmercouris commented 2 years ago

I wonder if it results in a different kind of mouse click when one long holds, maybe it is like mouse4 or something. If so, we should be able to do some mapping.

Ambrevar commented 2 years ago

See https://docs.gtk.org/gdk4/class.Event.html for the reference.

There is a way to get the time, but I don't know how to measure the duration of the press.

Ambrevar commented 2 years ago

There is also GDK_TOUCH_BEGIN and GDK_TOUCH_END. https://developer-old.gnome.org/gdk3/stable/gdk3-Events.html

Kabouik commented 2 years ago

There is also GDK_TOUCH_BEGIN and GDK_TOUCH_END. https://developer-old.gnome.org/gdk3/stable/gdk3-Events.html

If I am not mistaken, in Chromium as well as in Firefox, the text selection and handles to shrink or expand it (see first screenshot) appear after a certain touch duration but before the finger is lifted. It's actually the appearance of the text selection that gives the signal that the finger can be released, so I think this would be without GDK_TOUCH_END.

However if lifting the finger after a long presss is the best or the only way to measure touch duration in Webkit and trigger this special feature, then I think that would be perfectly fine too from a user persepctive.

hendursaga commented 2 years ago

Incidentally my laptop apparently has a touchscreen that I never use, I could help out with testing!

Ambrevar commented 2 years ago

That'd be great, thanks!