3rd party add-ons that used to work now don't with the webextentions version. Would it be possible to implement the switching of tabs by using the scrollwheel when hovering the tabs?
Because Firefox doesn't do it by default (for me. In some environment is this a default behavior of Firefox?), I think there is less reason to implement by self. However actually it is impossible to be done by another addon. So I think TST should provide ability to listen scroll event on its vertical tab bar via API.
Thank you @piroor this sound great. If TST provided a listener for scroll actions, another addon could handle changing the active tab. Would there also be a way to tell TST to not actually scroll? It would be irrelevant as long as there weren't enough tabs to overflow, but once there were, you could end up with both actions (tab changing, view scrolling) taking place.
thanks xamp for looking in to it :)
Now that I read "tab warming" exists, I'd want that too for the tab above/below :) see also: https://github.com/piroor/treestyletab/issues/1405 but that's not crucial at all.
A simple notification event seems not work as expected, because browser.runtime.sendMessage() is asynchronous. Even if TST handles DOM scroll event and send a notification to other addons, responses are received after the scroll event is processed by Firefox. So another API seems to be required to stop scrolling entirely by mouse wheel.
Another API request would be an event that would get raised when a tab is double clicked. I know a lot of people, myself included, like mapping various actions to double clicking a tab.
I've implemented new APIs to override wheel scroll.
See: https://github.com/piroor/treestyletab/wiki/API-for-other-addons#override-reaction-for-mouse-wheel-rotation-on-the-vertical-tab-bar
Awesome, thank you again. I'm going to do some learning and see what I can accomplish.
Okay, so first up, a disclaimer: I have no idea what I'm doing. I've never worked with webextensions before. If this is me being stupid, @piroor feel free to ignore me, you have way more important things you can be spending your time on.
Now, details: I have a very small test background.js working but I'm getting some mixed results. Here's the code.
const kTST_ID = '[email protected]';
async function registerToTST() {
var success = await browser.runtime.sendMessage(kTST_ID, {
type: 'register-self',
name: 'tst-scrolltochange',
style: '.tab {color: red;}'
});
console.log(success);
}
registerToTST();
async function disableScroll() {
var success = await browser.runtime.sendMessage(kTST_ID, {
type: 'scroll-lock'
});
console.log(success);
}
disableScroll();
browser.runtime.onMessageExternal.addListener((aMessage, aSender) => {
switch (aSender.id) {
case kTST_ID:
console.log(aMessage.type)
switch (aMessage.type) {
case 'scrolled':
if (aMessage.deltaY > 0) {console.log('down');}
if (aMessage.deltaY < 0) {console.log('up');}
}
break;
}
});
I can tell it registers correctly because the tabs all turn red, and in the console I see true true. The first time I scroll the wheel, I see scrolled down (or up) in the log, and the view does not scroll. However, future movements of the scroll wheel do not generate any more messages in the log, and the view scrolls like normal. Am I doing something wrong?
@xamphear
Many of the events/signals I've worked with (in the browser or in native toolkits like Qt) expect their handler to operate on a "return true if you want to keep listening" pattern. Have you tried that?
I'll keep looking into it.
EDIT: Yep, it looks like that's basically the case. You missed this from the example in the TST docs:
You must return any non-undefined value (including false, 0, and so on) from the listener. Otherwise TST guesses the listener addon is already unloaded and unlocks the scroll for your addon automatically.
@ssokolow You're absolutely right. I was missing the return Promise.resolve(true); line. Adding that makes everything work as it should. I told you I didn't know what I was doing!
Hey, we all have to start somewhere.
Alright, things are working better now, but when I examine the aMessage.tabs array of tab objects, almost all of them have "active: true". I was expecting only one to be active. Am I confused or mistaken?
I'm not a TMP developer, but that does have a higher chance of being a TMP bug.
According to the TMP docs, tabs is supposed to be an array of extended Tab objects and Tab.active is supposed to be the same as tabs.Tab.active, which MDN confirms to be the property for indicating which tab corresponds to the currently visible content pane.
Have you tried using get-tree directly instead?
The array returned by get-tree looks identical.
I don't know enough to feel confident opening a bug on it. It seems like one, but it could be something I'm doing, like not returning 'true' earlier. Anyway, there's an array in each tab object for the states, and "active" only appears if the tab is truly active, so I just programmed around using that.
The great news is I have it working! I'm sure there are edge cases I just haven't run into yet, but I can scroll up and down and change tabs with ease! It loops properly between the first and last tabs and everything. I'm sure I'll be back for some more help when I run into those edge cases, though.
Thank you again @piroor for adding these API calls and making this possible.
Sounds promising, thank you!
I'd be willing to test and find edge cases :) I'm good at breaking stuff.
removed
Alright, I have a signed build for testing, and the latest signed TST build has all the APIs I need. Should work on all versions of Firefox 57 and up, without disabling signature checks. Make sure you are running version 2.0.4 of TST at a minimum (that's the version on addons.mozilla.org right now) and then install this signed test build from my github repo releases page.
I do want to stress that I don't really know what I'm doing, and it probably isn't fair to piroor to use his github issues for stuff not related to his code. So this will probably be the last time I post something in here, unless I run into issues with TST itself. I set up a repo here for my extension:
@piroor You can probably close this now. You've done all that's needed to make this possible.
@joshuacant Yeah, it's a nice work! Thanks a lot!! If you find something error around TST APIs, please mention to me.
works like a charm. thanks so much josh
Most helpful comment
Alright, I have a signed build for testing, and the latest signed TST build has all the APIs I need. Should work on all versions of Firefox 57 and up, without disabling signature checks. Make sure you are running version 2.0.4 of TST at a minimum (that's the version on addons.mozilla.org right now) and then install this signed test build from my github repo releases page.
I do want to stress that I don't really know what I'm doing, and it probably isn't fair to piroor to use his github issues for stuff not related to his code. So this will probably be the last time I post something in here, unless I run into issues with TST itself. I set up a repo here for my extension:
https://github.com/joshuacant/tst-wheel_and_double