I am trying to create alternate keyboard shortcuts for TST by calling the messages it uses to handle said shortcuts, but I am not familiar with the code and don't know where to look.
I know it is the kind of thing that is easy when you what to look for and where, but addon APIs are not my forte.
Truth be told I should learn to locate where and how all addons handle keyboard shortcuts as TST will not be the only one.
Does anyone know how TreeStyleTabs handles keyboard shortcut
-
- Posts: 75
- Joined: November 16th, 2006, 11:16 am
- Location: Accra
-
- Posts: 6437
- Joined: February 3rd, 2009, 6:29 pm
Re: Does anyone know how TreeStyleTabs handles keyboard shor
You can set the keyboard shortcuts in the options.
i.e. about:addons > Extensions > Tree Style Tab > Options > Keyboard shortcuts
Tree Style Tab
http://addons.mozilla.org/firefox/addon/5890
Are you asking about the WebExtensions API or are you asking about some type of AutoConfig or userChrome.js hack to programmatically set the keyboard shortcuts?
WebExtensions API manifest.json commands
http://developer.mozilla.org/docs/Mozil ... n/commands
Piro uses the ShortcutCustomizeUI.js file to customize the keyboard shortcuts.
Generates configuration UI for keyboard shortcuts
http://github.com/piroor/webextensions- ... stomize-ui
P.S.
Addons are explicitly blocked from operating on another addon's moz-extension page.
How can I execute a userscript on a moz-extension page?
http://stackoverflow.com/questions/52131490
You can't execute a userscript on the about:addons page.
You can't hack the addon since it's signed.
i.e. about:addons > Extensions > Tree Style Tab > Options > Keyboard shortcuts
Tree Style Tab
http://addons.mozilla.org/firefox/addon/5890
Are you asking about the WebExtensions API or are you asking about some type of AutoConfig or userChrome.js hack to programmatically set the keyboard shortcuts?
WebExtensions API manifest.json commands
http://developer.mozilla.org/docs/Mozil ... n/commands
Piro uses the ShortcutCustomizeUI.js file to customize the keyboard shortcuts.
Generates configuration UI for keyboard shortcuts
http://github.com/piroor/webextensions- ... stomize-ui
P.S.
Addons are explicitly blocked from operating on another addon's moz-extension page.
How can I execute a userscript on a moz-extension page?
http://stackoverflow.com/questions/52131490
You can't execute a userscript on the about:addons page.
You can't hack the addon since it's signed.
-
- Posts: 75
- Joined: November 16th, 2006, 11:16 am
- Location: Accra
Re: Does anyone know how TreeStyleTabs handles keyboard shor
I asked him about how to call its functions from the SurfingKeys addon, and he gave me some pointers about it - it doesn't need registration and the link to the API Messages Indexmorat wrote:
Are you asking about the WebExtensions API or are you asking about some type of AutoConfig or userChrome.js hack to programmatically set the keyboard shortcuts?
WebExtensions API manifest.json commands
http://developer.mozilla.org/docs/Mozil ... n/commands
Piro uses the ShortcutCustomizeUI.js file to customize the keyboard shortcuts.
Generates configuration UI for keyboard shortcuts
http://github.com/piroor/webextensions- ... stomize-ui
From what I have learnt addons register some messages and their keyboard shortcuts to the addon system, probably in manifest.json, and the keyboard shortcuts UI, whether his own or the browsers Manage Extension Shortcuts page, will bind those defined or changed by the user to those events/messages.
What I am looking for are:
1. The files where those messages, events and their default shortcuts are registered to the addon system
2. The place where Firefox handles the keyboard shortcut events
3. The files provided by the addon developer where the messages/events are processed.
When you look at the keyboard shortcuts of TreeStyleTab in the Preferences page you see that many of the operations don't have default shortcuts, so there must be:
4. A file where TST reads the additional shortcuts defined by the user, and registers them and their related messages to Firefox. This is the file or files I am looking for.
TST is more complicated than other addons, but other addons must have similar features.
-
- Posts: 6437
- Joined: February 3rd, 2009, 6:29 pm
Re: Does anyone know how TreeStyleTabs handles keyboard shor
I got these keys working with Surfingkeys.
API for other addons
http://github.com/piroor/treestyletab/w ... her-addons
Surfingkeys
http://addons.mozilla.org/firefox/addon/886233
Sorry, I don't think I can help.
Code: Select all
mapkey("<Ctrl-a>", "Indent current tab", function () {
browser.runtime.sendMessage("treestyletab@piro.sakura.ne.jp", {
type: "indent",
tab: "current",
followChildren: false,
});
});
mapkey("<Ctrl-b>", "Outdent current tab", function () {
browser.runtime.sendMessage("treestyletab@piro.sakura.ne.jp", {
type: "outdent",
tab: "current",
followChildren: false,
});
});
mapkey("<Ctrl-c>", "Collapse tree current tab", function () {
browser.runtime.sendMessage("treestyletab@piro.sakura.ne.jp", {
type: "collapse-tree",
tab: "current",
});
});
mapkey("<Ctrl-d>", "Expand tree current tab", function () {
browser.runtime.sendMessage("treestyletab@piro.sakura.ne.jp", {
type: "expand-tree",
tab: "current",
});
});
http://github.com/piroor/treestyletab/w ... her-addons
Surfingkeys
http://addons.mozilla.org/firefox/addon/886233
Sorry, I don't think I can help.
-
- Posts: 75
- Joined: November 16th, 2006, 11:16 am
- Location: Accra
Re: Does anyone know how TreeStyleTabs handles keyboard shor
morat wrote:I got these keys working with Surfingkeys.
API for other addonsCode: Select all
mapkey("<Ctrl-a>", "Indent current tab", function () { browser.runtime.sendMessage("treestyletab@piro.sakura.ne.jp", { type: "indent", tab: "current", followChildren: false, }); }); mapkey("<Ctrl-b>", "Outdent current tab", function () { browser.runtime.sendMessage("treestyletab@piro.sakura.ne.jp", { type: "outdent", tab: "current", followChildren: false, }); }); mapkey("<Ctrl-c>", "Collapse tree current tab", function () { browser.runtime.sendMessage("treestyletab@piro.sakura.ne.jp", { type: "collapse-tree", tab: "current", }); }); mapkey("<Ctrl-d>", "Expand tree current tab", function () { browser.runtime.sendMessage("treestyletab@piro.sakura.ne.jp", { type: "expand-tree", tab: "current", }); });
http://github.com/piroor/treestyletab/w ... her-addons
Surfingkeys
http://addons.mozilla.org/firefox/addon/886233
Sorry, I don't think I can help.
Thanks, I was able to make some progress with your example.
Is there a way of testing in the customizations to know if the mapkey functions work background or content scripts?
I tried many of the functions from SurfingKeys and they don't seem to work.
-
- Posts: 6437
- Joined: February 3rd, 2009, 6:29 pm
Re: Does anyone know how TreeStyleTabs handles keyboard shor
If the code is executed as a background script, then location.href property is (1) in the browser console, like when using the about:debugging page.voipfc wrote:Is there a way of testing in the customizations to know if the mapkey functions work background or content scripts?
If the code is executed as a content script, then location.href property is (2) in the browser console.
1. moz-extension://{UUID}/_generated_background_page.html
2. http://www.mozillazine.org/
Test page
http://www.mozillazine.org/
Code: Select all
mapkey("<Ctrl-a>", "Browser console test", function () {
console.log(location.href);
});
mapkey("<Ctrl-b>", "Tab create test 1", function () {
// fails
browser.tabs.create({
url: "http://www.example.com/",
active: true,
});
});
mapkey("<Ctrl-c>", "Tab create test 2", function () {
tabOpenLink("http://www.example.com/");
});
mapkey("<Ctrl-d>", "Clipboard test", function () {
Clipboard.write("test abc 123");
});
Surfingkeys default mappings
http://github.com/brookhong/Surfingkeys ... default.js
Surfingkeys example mappings
http://gist.github.com/search?q=Surfingkeys+mapkey
http://gist.github.com/minhoolee/ed69ba ... 94d1287ef1
tabOpenLink function is defined in utils.js
http://github.com/brookhong/Surfingkeys ... s/utils.js
Clipboard module is defined in content_scripts.js
http://github.com/brookhong/Surfingkeys ... scripts.js