Insert Text

Last post 08-26-2004, 6:16 PM by Deech. 6 replies.
Sort Posts: Previous Next
  •  07-26-2004, 4:33 PM 1324

    Insert Text

    If I wanted to make an exterior button that will insert some specific text at the current cursor location in the editor, what's the best way to accomplish that? I saw something about an "innertext" property, but I couldn't find it in the manual. I know you have custom buttons for the Editor coming in a future release, so for the time being, the best way to do something like this is with an external button or link (i.e. I want to generate dynamic links that will change depending upon a user's setting).

     
    I can look through the WINie.js file and probably rig something together, but if there's a native way to insert text or HTML at the cursor location, I'd rather use that.
     
    Thanks for your support. You've been very helpful, and the CuteEditor is top notch!
  •  07-27-2004, 11:28 AM 1329 in reply to 1324

    Re: Insert Text

    Thanks for the nice words.

     
     
    The easiest way is use the links dropdown and Code Snippet dropdown. Please check the above example.
     
    let me know if you have any further questions.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  07-28-2004, 2:52 PM 1357 in reply to 1329

    Re: Insert Text

    Thanks, Adam.

     
    Unfortunately the code snippet dropdown will only work for static inserts (that is, dynamic when the page is created, but not dynamic once the page is rendered). In other words, I need to have a button that the user presses that will open a new window, allow the user to type in some stuff, then perform the insert using the dynamic information that the user just entered. All I need to know is how to insert something in the editor at the cursor's spot, and I can handle the rest.
     
    I'll start poking around WinIE.js, but if there is an easier way, your assistance is greatly appreciated (well, it's appreciated regardless ).
     
    Thanks!
  •  07-28-2004, 2:55 PM 1358 in reply to 1357

    Re: Insert Text

    I think I may have found the answer. In WinIE.js there is a Javascript function used as follows:

     
    insertHTML(current.EditorID, html);
     
    where current is the editor object and html is the content to be inserted. I'll give that a whirl and see what happens.
     
  •  07-28-2004, 3:08 PM 1359 in reply to 1358

    Re: Insert Text

    Yes, that did the trick. Please let me know if I am using it incorrectly and will end up crashing the editor or something, lol!
  •  08-26-2004, 6:08 PM 1624 in reply to 1359

    Re: Insert Text

    Ok, I had that working within the same window, but if I open a new window, how do I access the Editor object within the parent window from the opened window?

     
    For example, I created a wrapper function for insertHTML where I pass Editor1 as the Editor object. My function is defined as follows (this is all Javascript, not VBScript):
     
    function insert_content(current, content) {
        insertHTML(current.EditorID, content);
    }
     
    Within that page, I can call the function within a link to insert text at the current cursor position as follows:
     
    <a href=insert_content(Editor1, 'Sample Text');">Insert Sample Text </a>
     
    I can call the function from a popup window as follows:
     
    window.opener.insert_content(window.opener.document.Editor1, 'Sample Text');
     
    However, I get a Javascript error that Editor1 is null or not an object. I think the window.opener.document.Editor1 is wrong, but what should I put there?
     
    window.opener.insert_content(Editor1, 'Sample Text'); doesn't work either, as I would expect it wouldn't, since it is calling the function (and referencing the Editor1 object) on the main window from the popup window.
     
    This is CuteEditor for ASP version 2.2
     
    Any help would save me a bundle of trial and error time, although I am not sure what to try next.
     
    Many thanks in advance!
     
     
     
     
  •  08-26-2004, 6:16 PM 1625 in reply to 1624

    Re: Insert Text

    What a doofus I am! The answer is to use:

     
    window.opener.insert_content(window.opener.Editor1, 'Sample Text');
     
    and not:
     
    window.opener.insert_content(window.opener.document.Editor1, 'Sample Text');
     
    In other words, leave off the document. Sorry for the premature post. But maybe this will help someone else.
     
    Cheers!
View as RSS news feed in XML