From:  "Sekmet" <sekmet2600@gmail.com>
Date:  23 May 2005 22:05:44 Hong Kong Time
Newsgroup:  news.mozilla.org/netscape.public.mozilla.editor
Subject:  

cmd_insertText Function Problem, please help!

NNTP-Posting-Host:  201.0.49.55

I`m writing a extension to mozilla and using function bellow to insert
text on document.
Works very well, but i would like know if is possible select the
location where to insert text.
Function bellow insert some text at cursor position only.
Can Someone help me with this? or tell me if is possible do this?

Thanks in advance
Best Regards
Carlos


function insertText(aText) {
  try {
    var command = "cmd_insertText";
    var controller =
document.commandDispatcher.getControllerForCommand(command);
    if (controller && controller.isCommandEnabled(command)) {
      controller =
controller.QueryInterface(Components.interfaces.nsICommandController);
      var params =
Components.classes["@mozilla.org/embedcomp/command-params;1"];
      params =
params.createInstance(Components.interfaces.nsICommandParams);
      params.setStringValue("state_data", aText);
      controller.doCommandWithParams(command, params);
    }
  }
  catch (e) {
    dump("Can't do cmd_insertText! ");
    dump(e+"\n")
  }
}