nsITextInputProcessorCallback

A callback interface for nsITextInputProcessor user
1.0
35.0.1
Introduced
Gecko 38
Inherits from: 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;
    }
    ...
  },
}

Method overview

boolean onNotify(in nsITextInputProcessor aTextInputProcessor, in nsITextInputProcessorNotification aNotification);

Methods

onNotify()

Requires Gecko 38 (Firefox 38 / Thunderbird 38 / SeaMonkey 2.35)

This is called when Gecko requests or notifies something to IME.

boolean onNotify(in nsITextInputProcessor aTextInputProcessor,
                 in nsITextInputProcessorNotification aNotification);
Parameters
aTextInputProcessor
The instance which receives the notification. If the handler needs to do something with composition, you can use this.
aNotification
A notification or request. See the document of nsITextInputProcessorNotification for the details.
Return value

If this handles the notification normally or does nothing, it should return true. Otherwise, false.

Document Tags and Contributors

 Contributors to this page: Masayuki, kscarfone
 Last updated by: Masayuki,