when you click on the "add to dictionary" label in firefox's context menu, it calls this function:
Code:
oncommand="InlineSpellCheckerUI.addToDictionary();"/>
I'm trying to replicate that programmatically in a firefox extension. So it seems the first step is including this file in the xul:
chrome://global/content/inlineSpellCheckUI.js
which basically is just an include of this file:
resource://gre/modules/InlineSpellChecker.jsm
(these links both need to be opened in firefox, obviously)
so then in the jsm file we find the function:
Code:
// callback for adding the current misspelling to the user-defined dictionary
addToDictionary: function()
{
// Prevent the undo stack from growing over the max depth
if (this.mAddedWordStack.length == MAX_UNDO_STACK_DEPTH)
this.mAddedWordStack.shift();
this.mAddedWordStack.push(this.mMisspelling);
this.mInlineSpellChecker.addWordToDictionary(this.mMisspelling);
}
But what I want to do is add a word to the dictionary on a button click (or oncommand as xul would have it). So I was thinking this might work:
Code:
<button id="SpellcheckerAddButton" label="&addbutton.label;" oncommand="InlineSpellCheckerUI.mInlineSpellChecker.addWordToDictionary('fuzzlebuzz')"/>
I've included the chrome://global/content/inlineSpellCheckUI.js in the xul file where the button is, but I suspect that I'm misunderstanding the "this" from the original jsm file, because it doesn't work (and because it's xul, debugging is a nightmare).
Any suggestions?