Selected Text for Command UI Window

Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default Selected Text for Command UI Window

    I'm creating my first Dreamweaver Custom Command. I want to use the selected
    text in the document for JavaScript to wrap into a custom tag. However, I want
    the Command UI input to value the selected text. Basically, if no text is
    selected it just simply inserts the text entered from the input field, but if
    there is text selected then I don't the input field to be empty.

    jgiotta Guest

  2. Similar Questions and Discussions

    1. How to suppress popups of annotation andsticky note in a selected window?
      I have opened several AVWindows for the same AVDoc and want to suppress (minimize) popups of annotation and sticky note in a certain window. The...
    2. Opening a Selected Tab in a new Window.
      I have a TabBar object which is populated with a ViewStack, which consists of 7 different components (first code segment). What I want, is that when...
    3. How to get selected text from pdf using sdk
      Hi, I am using following code in VB to get selected text from pdf. Dim jso As Object Dim gApp As Acrobat.CAcroApp Dim gPdDoc As...
    4. current selected text to highlighted text on mouse up event through java script
      hi everybody, I want to convert the current selected text to highlighted text i.e. to yellow background on mouse up event on pdf form through...
    5. How to get selected text using IAC API?
      In fact i need this: after user selects text (or rectangular part of pdf documents content) i have to be able to get page number and coordinates of...
  3. #2

    Default Re: Selected Text for Command UI Window

    jgiotta wrote:
    > I'm creating my first Dreamweaver Custom Command. I want to use the selected
    > text in the document for JavaScript to wrap into a custom tag. However, I want
    > the Command UI input to value the selected text. Basically, if no text is
    > selected it just simply inserts the text entered from the input field, but if
    > there is text selected then I don't the input field to be empty.
    To get the user's selection you can use the following code:
    var dom = dw.getDocumentDOM()
    var sel = dom.getSelection();
    var html = dom.documentElement.outerHTML;

    // see what the selection is
    // can use this to set the value of your text field.
    alert(html.substring(sel[0],sel[1]));


    But you can test the offsets within sel to see if there is anything
    selected. If sel[0] and sel[1] are equal then there is nothing selected,
    there is only an insertion point.



    --
    Danilo Celic
    | Extending Knowledge Daily : [url]http://CommunityMX.com/[/url]
    | Team Macromedia for Dreamweaver : [url]http://macromedia.com/go/team/[/url]
    danilocelic *TMM* Guest

  4. #3

    Default Re: Selected Text for Command UI Window

    I figured out a solution. In the HTML document for the UI, I added a onLoad
    event to the body tag. It grabs the selected text and populates the input
    field. Example:

    function myValue(input) {
    var theDOM = dw.getDocumentDOM();
    var theDocEl = theDOM.documentElement;
    var theWholeDoc = theDocEl.outerHTML;
    var theSelNode = theDOM.getSelectedNode();
    var theSel = theDOM.getSelection();
    var selText = theWholeDoc.substring(theSel[0],theSel[1]);
    input.value = selText;
    }

    jgiotta Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139