nsISupports
Last changed in Gecko 38.0 (Firefox 38.0 / Thunderbird 38.0 / SeaMonkey 2.35)nsITextInputProcessorCallback is defined for receiving requests and notifications to IME from Gecko. This interface has a "function" attribute. Therefore, JS-IME can implement this as a function.
Example of simple JS-IME:
var simpleIME = { _hasFocus: false, _hasRightsToCompose: false, _TIP: null, _callback: function simpleIME_callback(aTIP, aNotification) { try { switch (aNotification.type) { case "request-to-commit": aTIP.commitComposition(); break; case "request-to-cancel": aTIP.cancelComposition(); break; case "notify-focus": this._hasFocus = true; break; case "notify-blur": this._hasFocus = false; break; case "notify-detached": this._hasFocus = false; this._hasRightsToCompose = false; break; } return true; } catch (e) { return false; } }, setComposition: function simpleIME_setComposition(aText, aClauses, aCaret) { if (!this._TIP) { this._TIP = Components.classes["@mozilla.org/text-input-processor;1"]. createInstance(Components.interfaces.nsITextInputProcessor); } if (!this._TIP.beginInputTransaction(window, this._callback)) { return false; } ... }, }
boolean onNotify(in nsITextInputProcessor aTextInputProcessor, in nsITextInputProcessorNotification aNotification); |
This is called when Gecko requests or notifies something to IME.
boolean onNotify(in nsITextInputProcessor aTextInputProcessor, in nsITextInputProcessorNotification aNotification);
nsITextInputProcessorNotification
for the details.If this handles the notification normally or does nothing, it should return true. Otherwise, false.