MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
morat
 
Posts: 3843
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 23rd, 2016, 5:42 am

@bege

The original code works great for me.

Keyconfig 20110522
Firefox Portable 43.0.4 (Hungarian) with a fresh profile
Windows 7 SP1 32-bit

I installed the en-US dictionary via AMO.

I use Ctrl+Shift+1 for the en-US locale and Ctrl+Shift+2 for the hu locale.

Test text: cat macska

Firefox Portable
http://sourceforge.net/projects/portabl ... ble%20Ed./

United States English Spellchecker
http://addons.mozilla.org/firefox/addon/3497

Test page
http://developer.mozilla.org/en-US/docs ... t/textarea

I bet avada has a screwed up "cleanish" test profile. And avada should be testing on the release build since Mozilla sometimes turns stuff on by default on beta for a select few, like e10s.

avada
 
Posts: 1854
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted January 23rd, 2016, 6:49 am

morat wrote:I bet avada has a screwed up "cleanish" test profile. And avada should be testing on the release build since Mozilla sometimes turns stuff on by default on beta for a select few, like e10s.

Nope. I actually tried with a brand new profile since then. It didn't work.

Now I tried it with stable 43.0.4 and it works with that. (The toggle variant too.) I tried en/hu also win32/win64. And no, I don't have e10s enabled.
So in conclusion all of you can expect it to break when in a few days FF44 is released.

Edit: I tried FF44 RC2 en-US win32, to test the most ordinary/common version. It didn't work with that either.

morat
 
Posts: 3843
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 26th, 2016, 4:19 pm

@avada
@bege

The original code works for me in Firefox 44 if I force a window repaint.

Code: Select all
var dictionary = "en-US";
var Cc = Components.classes;
var Ci = Components.interfaces;
Cc["@mozilla.org/spellchecker/engine;1"].
  getService(Ci.mozISpellCheckingEngine).
    dictionary = dictionary;
var nsIContentPrefService2 = Cc["@mozilla.org/content-pref/service;1"].
  getService(Ci.nsIContentPrefService2);
var target = document.commandDispatcher.focusedWindow;
if (target == window) target = content;
var loadContext = target.QueryInterface(Ci.nsIInterfaceRequestor).
  getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsILoadContext);
nsIContentPrefService2.set(target.location, "spellcheck.lang", dictionary, loadContext, {
  handleResult: function (result) {},
  handleError: function (error) {},
  handleCompletion: function (completion) {
    alert("force a window repaint");
  },
});
Services.prefs.setCharPref("spellchecker.dictionary", dictionary);

I'm using an alert in the callback to force a window repaint.

https://developer.mozilla.org/en-US/doc ... efService2
https://developer.mozilla.org/en-US/doc ... fCallback2

avada
 
Posts: 1854
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted January 27th, 2016, 3:47 am

morat wrote:@avada
@bege

The original code works for me in Firefox 44 if I force a window repaint.

Code: Select all
var dictionary = "en-US";
var Cc = Components.classes;
var Ci = Components.interfaces;
Cc["@mozilla.org/spellchecker/engine;1"].
  getService(Ci.mozISpellCheckingEngine).
    dictionary = dictionary;
var nsIContentPrefService2 = Cc["@mozilla.org/content-pref/service;1"].
  getService(Ci.nsIContentPrefService2);
var target = document.commandDispatcher.focusedWindow;
if (target == window) target = content;
var loadContext = target.QueryInterface(Ci.nsIInterfaceRequestor).
  getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsILoadContext);
nsIContentPrefService2.set(target.location, "spellcheck.lang", dictionary, loadContext, {
  handleResult: function (result) {},
  handleError: function (error) {},
  handleCompletion: function (completion) {
    alert("force a window repaint");
  },
});
Services.prefs.setCharPref("spellchecker.dictionary", dictionary);

I'm using an alert in the callback to force a window repaint.

https://developer.mozilla.org/en-US/doc ... efService2
https://developer.mozilla.org/en-US/doc ... fCallback2


Indeed it does. However the annoying alert negates its value. It also works if I add it to your variant which cycles between dictionaries.

I think a more elegant solution is required to force a repaint for this to remain useful in practice.

morat
 
Posts: 3843
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 27th, 2016, 6:20 am

avada wrote:I think a more elegant solution is required to force a repaint for this to remain useful in practice.

Find:

Code: Select all
alert("force a window repaint");

Replace with:

Code: Select all
var focusedElement = document.commandDispatcher.focusedElement;
focusedElement.blur();
focusedElement.focus();

avada
 
Posts: 1854
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted January 27th, 2016, 3:50 pm

morat wrote:
avada wrote:I think a more elegant solution is required to force a repaint for this to remain useful in practice.

Find:

Code: Select all
alert("force a window repaint");

Replace with:

Code: Select all
var focusedElement = document.commandDispatcher.focusedElement;
focusedElement.blur();
focusedElement.focus();

Thanks. It seems to work fine now.

avada
 
Posts: 1854
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted January 28th, 2016, 2:55 am

Do you use anything to tell which one is active?
I also installed quick locale switcher to have some visual feedback of what language is selected. (Otherwise broken in the same way this script was).
What would be even nicer if I found one that shows the country flag in the actual textbox that has focus.

morat
 
Posts: 3843
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 28th, 2016, 1:12 pm

@jpfleury

The default actions for shortcuts 0 through 9 are available to disable.

Name: key_tag0, Shortcut: shift+any+0, Code: goDoCommand("cmd_removeTags");
Name: key_tag1, Shortcut: shift+any+1, Code: goDoCommand("cmd_tag1");
Name: key_tag2, Shortcut: shift+any+2, Code: goDoCommand("cmd_tag2");
Name: key_tag3, Shortcut: shift+any+3, Code: goDoCommand("cmd_tag3");
Name: key_tag4, Shortcut: shift+any+4, Code: goDoCommand("cmd_tag4");
Name: key_tag5, Shortcut: shift+any+5, Code: goDoCommand("cmd_tag5");
Name: key_tag6, Shortcut: shift+any+6, Code: goDoCommand("cmd_tag6");
Name: key_tag7, Shortcut: shift+any+7, Code: goDoCommand("cmd_tag7");
Name: key_tag8, Shortcut: shift+any+8, Code: goDoCommand("cmd_tag8");
Name: key_tag9, Shortcut: shift+any+9, Code: goDoCommand("cmd_tag9");

I disabled the default shortcut with the name key_tag1 and I created a new shortcut with the following code.

Code: Select all
goDoCommand("cmd_removeTags");
goDoCommand("cmd_tag1");

It works here.

P.S.

These commands are equivalent.

Code: Select all
goDoCommand("cmd_removeTags");

Code: Select all
RemoveAllMessageTags();

These commands are equivalent.

Code: Select all
goDoCommand("cmd_tag1");

Code: Select all
ToggleMessageTagKey(1);

morat
 
Posts: 3843
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 28th, 2016, 1:17 pm

@avada

No, I don't use anything special.

P.S.

The developer ppclick (pay per click) is a spyware author. I know since I reviewed the Copy Link Name extension.

Copy Link Name
http://addons.mozilla.org/firefox/addon/553

Quick Locale Switcher
http://addons.mozilla.org/firefox/addon/1333

jpfleury
 
Posts: 8
Joined: February 11th, 2009, 11:26 am

Post Posted January 28th, 2016, 7:06 pm

@morat

Thanks a lot! It works great, and it'll be very useful. Where can I read documentation about these functions? I would like to apply two other modifications to my shortcuts but I don't know where to start to familiarize myself with this.

For example, I would like to add a command to toggle "Watch Thread" (shortcut W) only if the thread is watched, so something like that:


Code: Select all
if thread is watched then {
    goDoCommand('cmd_watchThread'); // It toggles watch thread status.
}
goDoCommand("cmd_removeTags");
goDoCommand("cmd_tag1");



The other modification would be to apply tags only to the first message of a thread:


Code: Select all
if thread is watched then {
    goDoCommand('cmd_watchThread'); // It toggles watch thread status.
}
find the first message of the current thread then {
    goDoCommand("cmd_removeTags");
    goDoCommand("cmd_tag1");
}



Would you have any clues about that, or documentation to point out, or maybe another forum if these questions are not suitable for the current one?

Thanks again for your help!

morat
 
Posts: 3843
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 28th, 2016, 9:21 pm

@jpfleury

Try this:

Code: Select all
if (gFolderDisplay.selectedMessageThreadWatched) {
  goDoCommand("cmd_watchThread");
}
goDoCommand("cmd_removeTags");
goDoCommand("cmd_tag1");

http://mxr.mozilla.org/comm-esr38/searc ... ommands.js
http://mxr.mozilla.org/comm-esr38/searc ... Display.js

I don't know the solution to the second request.

jpfleury wrote:Where can I read documentation about these functions?

I answered a similar question in the following thread.

viewtopic.php?p=14450843#p14450843
viewtopic.php?p=14451395#p14451395

Edit:

jpfleury wrote:find the first message of the current thread

Try this:

Code: Select all
// move thread pane selection to top
var treeBoxObject = document.getElementById("threadTree").treeBoxObject;
treeBoxObject.ensureRowIsVisible(0);
treeBoxObject.view.selection.select(0);

viewtopic.php?p=13135019#p13135019
Last edited by morat on January 28th, 2016, 10:24 pm, edited 1 time in total.

jpfleury
 
Posts: 8
Joined: February 11th, 2009, 11:26 am

Post Posted January 28th, 2016, 9:29 pm

@morat

Thanks again! Much appreciated! I'll look at the links you pointed out.

r1212
 
Posts: 3
Joined: February 3rd, 2016, 1:43 am

Post Posted February 3rd, 2016, 1:58 am

hello, I am new to this forum. I hope this is the right way to post a question.

I use Iceweasel and have installed Keyconfig and successfully created shortcut keys shftH and shftT for viewing message body as HTML and plain text respectively. The both work as expected.

On the documentation page,some code provided to TOGGLE between those states. I created key shftZ with that code, but this key does nothing. The code is:
Toggle message body between plain text and HTML:

pref.getBoolPref("mailnews.display.prefer_plaintext")?MsgBodyAllowHTML():MsgBodyAsPlaintext()

I suspect that the syntax of the construction or the getBoolPref call is not OK, because if I swap the two functions, nothing happens either. But if I only put one function call in it, the shortcut works, so the keydefinition does work.

Can anyone give me advice how to tackle/debug this?

regards, Ruud

r1212
 
Posts: 3
Joined: February 3rd, 2016, 1:43 am

Post Posted February 3rd, 2016, 5:51 am

I found the solution elsewhere in this thread:
pref is replaces by Service.prefs

But I have another issue: in trying to switch the folder pane to type All, I made a key that does loadFolderView(0)

But nothing happens and the error console says 'ReferenceError: loadFolderView is not defined' chrome://messenger/content/messenger.xul

any thoughts on this?

regards, Ruud

morat
 
Posts: 3843
Joined: February 3rd, 2009, 6:29 pm

Post Posted February 3rd, 2016, 6:49 am

@r1212

When you say "I use Iceweasel" I think of Firefox, not Thunderbird.

AFAIK, Iceweasel is Firefox. Icedove is Thunderbird. Iceape is SeaMonkey.

Try these:

Code: Select all
// toggle folder views between all and unread
if (gFolderTreeView.mode == "unread") {
  gFolderTreeView.mode = "all";
} else {
  gFolderTreeView.mode = "unread";
}

Code: Select all
// toggle mail views between all and unread
if (document.getElementById("viewPicker").label == "Unread") {
  if ("ViewChangeByValue" in window) ViewChangeByValue(0);
  else ViewChange(0);
} else {
  if ("ViewChangeByValue" in window) ViewChangeByValue(1);
  else ViewChange(1);
}

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 5 guests