tbkeys
tbkeys copied to clipboard
[FR] func with params
e.g.
"shift+a": "func:loadFolderView(0)",
"shift+s": "func:loadFolderView(2)",
Hello ! I don't understand the post above, but I'm interested with the mean to define a shortcut to set the font color of the selected text to red (for instance…). In the compose window, of course ! Is it possible ? How ? The command fontColor has to be used with a parameter… Thanks, Mist
You can create a keyboard shortcut that executes a custom command with the tbkeys addon.
@ildar
You are using obsolete code from Thunderbird 2.0.
More info...
http://forums.mozillazine.org/viewtopic.php?f=39&t=2925785
@Mist44230
Try this:
window.EditorSetTextProperty('font', 'color', '#ff0000');
window.goUpdateCommandState('cmd_fontColor');
Tips...
http://forums.mozillazine.org/viewtopic.php?p=14872763#p14872763
Hi morat, Thanks for your answer. I had searched on Geckozone but not on mozillazine, I will learn the lesson ! But I don't manage to find the correct syntax in tbkeys settings :-( Could you help me again ? After reading mozillazine I've tried this (in compose key bindings) :
"ctrl+r": "func: (function () {
window.EditorSetTextProperty('font', 'color', '#ff0000');
window.goUpdateCommandState('cmd_fontColor');}) ();"
And some variants, without success…
Mist
@Mist44230
Did you remember to remove the newline characters in the code snippet so the input is a valid JSON string?
Did you remember to remove the trailing comma after the last key so the input is a valid JSON string?
Try the following compose key bindings in settings using the tbkey addon.
{
"ctrl+1": "window.EditorSetTextProperty('font', 'color', '#ff0000'); window.goUpdateCommandState('cmd_fontColor');",
"ctrl+2": "window.EditorSetTextProperty('font', 'color', '#00ff00'); window.goUpdateCommandState('cmd_fontColor');",
"ctrl+3": "window.EditorSetTextProperty('font', 'color', '#ff00ff'); window.goUpdateCommandState('cmd_fontColor');"
}
JSON Validator...
http://jsonlint.com/
Many thanks morat,
So simple solution, works fine !
I had nevertheless applied myself, but I wondered if "func" or "function" were necessary, ultimately neither !!
Mist
@Mist44230
Use the cmd shorthand for calling a command using the goDoCommand method.
For example, "cmd:cmd_nextMsg" is the same as "window.goDoCommand('cmd_nextMsg');".
Use the func shorthand for calling a function on the window object without a parameter.
For example, "func:MsgNewMessage" is the same as "window.MsgNewMessage();".
Use (function(){...})(); when creating a variable with the var statement.
e.g.
(function () {
var color = '#ff0000';
window.EditorSetTextProperty('font', 'color', color);
window.goUpdateCommandState('cmd_fontColor');
})();
You're welcome.
This doesn' work for me:
"shift+a": "window.loadFolderView(0);", "shift+s": "window.loadFolderView(2);",
@ildar
Try the following code snippets using the tbkeys addon.
window.gFolderTreeView.mode = 'all';
window.gFolderTreeView.mode = 'unread';
window.gFolderTreeView.mode = 'favorite';
window.gFolderTreeView.mode = 'smart';
window.gFolderTreeView.mode = 'unread_compact';
window.gFolderTreeView.mode = 'favorite_compact';
window.gFolderTreeView.mode = 'recent_compact';
You cannot execute arbitrary javascript using the tbkeys-lite addon.
I'm sorry, one last time. This didn't work for me: { "shift+a": "window.gFolderTreeView.mode = 'all';", "shift+s": "window.gFolderTreeView.mode = 'favorite';" } How to do it right?
@ildar
I tried the following main key bindings in settings using the tbkey addon. It works for me.
{
"shift+a": "window.gFolderTreeView.mode = 'all';",
"shift+s": "window.gFolderTreeView.mode = 'favorite';"
}
Try running the code snippets using the error console.
Instructions:
- open error console i.e. tools > developer tools > error console
- copy and paste code snippet into error console
- press enter to run
Error Console command line http://developer.mozilla.org/docs/Tools/Browser_Console#Browser_Console_command_line
There may be a conflict with another addon. Try disabling all addons except the tbkey addon, then restart and test again.
It is easy to misunderstand, and interpret the following from documentation to that you can't use parameters in the keybindings:
Simple function calls: These follow the format func:<func_name> where <func_name> is a function defined on the Thunderbird window object. That function is called without any arguments.
However, you can do that, but with a longer syntax.
The following will map the single character "o" to move the currently selected email to a specific folder:
"o": "window.MsgMoveMessage(window.MailUtils.getExistingFolder('imap://[email protected]/folder/path'))",
I took me a while to figure out the syntax, especially since the official documentation of the MsgMoveMessage and MailUtils are not up to date, and describes outdated syntax and function names.