xiaoxiaoflood / firefox-scripts

userChromeJS / autoconfig.js and extensions
Mozilla Public License 2.0
1k stars 85 forks source link

Mouse Gestures Scroll To Top #36

Closed zakius closed 4 years ago

zakius commented 4 years ago

Hello, first of all I'd like to thank you for sharing your work. As I can see you have scroll to top action bound in gestures script but I can't get it to work any way, most likely it should replicate scroll to bottom (sending keystroke), but I can't figure out what would be the code for Home button (obviously changing 23 to 24 in that number doesn't work). Do you have any reference how to find these codes?

xiaoxiaoflood commented 4 years ago

Hi,

Maybe you're using an outdated code? Mouse Gestures uses cmd_moveBottom and cmd_moveTop.

Do you have any reference how to find these codes?

https://searchfox.org/mozilla-central/source/testing/mochitest/tests/SimpleTest/NativeKeyCodes.js

zakius commented 4 years ago

Thanks for the quick reply

These commands don't work for me for some reason, maybe there's some version mismatch or other issue, I'll look into it one more time. And thank you for that list

ganego commented 4 years ago

I use a different script that calls one of these function: https://developer.mozilla.org/en-US/docs/Archive/Mozilla/XUL/List_of_commands

Specifically cmd_scrollTop. Don't know if this is possible here.

zakius commented 4 years ago

Just letting you know I figured it out

first of all this command works but has to be called in the right context, directly in the mousedown handler

secondly I had some issues with making rocker left work properly which may have caused false negatives, in particular deselect command was messing with it, for my usecase it doesn't really matter so I just commented it out and now it does what I expect

thanks again

xiaoxiaoflood commented 4 years ago

first of all this command works but has to be called in the right context, directly in the mousedown handler

Which command? I use cmd_moveBottom and cmd_moveTop in mouseup handler, like all mouse gestures. Rocker gestures are handled by mousedown and scroll gestures by wheel.

I use a different script that calls one of these function (...) Specifically cmd_scrollTop

Do you have an example where scrollTop/scrollBottom work and moveBottom/moveTop don't? I think they and cmd_[begin|end]Line are essentially the same.

Windows and Linux uses cmd_[begin|end]Line for Home/End keys in browser context, while Mac uses cmd_scroll[Top|Bottom].

zakius commented 4 years ago

I'm not sure if I use move or scroll, will check tomorrow, but what I meant it doesn't work in chromeListener at all, so I gave up on sending message from mousedown handler and executed these commands directly there

xiaoxiaoflood commented 4 years ago

So I got two examples where gesture to scrollup/down doesn't work:

I already fixed that and will push the update soon.

zakius commented 4 years ago

Do you mind if I submit PR with improved configurability? I'd build array of available actions and map gestures to them somewhere at the top of the script to make it clearer and easier to update for people who customized their bindings

EDIT: as I'm digging deeper into it it seems it may be quite challenging to do it properly due to some gestures requiring context and some performing different tasks depending on context, I'll play around a bit more but may give up on that

EDIT 2: okay, I'm giving up on this, I only end up breaking stuff all the time

xiaoxiaoflood commented 4 years ago

Go ahead! But yes, I think it's not so easy at it may seen. I didn't actually write the script to make it easily configurable.

xiaoxiaoflood commented 4 years ago

Closing this one because it's working for me, I can't reproduce any issue.