Code Monkey home page Code Monkey logo

Comments (11)

Mist44230 avatar Mist44230 commented on May 27, 2024

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

from tbkeys.

morat523035 avatar morat523035 commented on May 27, 2024

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

from tbkeys.

Mist44230 avatar Mist44230 commented on May 27, 2024

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

from tbkeys.

morat523035 avatar morat523035 commented on May 27, 2024

@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/

from tbkeys.

Mist44230 avatar Mist44230 commented on May 27, 2024

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

from tbkeys.

morat523035 avatar morat523035 commented on May 27, 2024

@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.

from tbkeys.

ildar avatar ildar commented on May 27, 2024

from tbkeys.

morat523035 avatar morat523035 commented on May 27, 2024

@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.

from tbkeys.

ildar avatar ildar commented on May 27, 2024

from tbkeys.

morat523035 avatar morat523035 commented on May 27, 2024

@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.

from tbkeys.

Olen avatar Olen commented on May 27, 2024

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.

from tbkeys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.