× Warning! This forum is in archival status. New contributions may not work.
[campsite-dev] another small function.
  • Nenad,
    Thanks a lot for your function, it worked at the first try.
    I dont want to abuse, but, can you give me some pointers on how to
    correct a weird behavour in the applet?

    ill try to explain what is happening now:

    lets suppose we write the following:

    "This is a Link composed of several words and this is the rest of the
    text"

    if we add an external link to "Link composed of several words"

    the final document when we save it would be:

    "This is a Link composed of several
    words and this is the rest of the text"

    and "Link composed of several words" would display with a blue underline
    in the editor.

    right?

    now, i have noticed that if you double click on any of the words "Link",
    "composed", "of", "several", "words" or even on the spaces between them.
    the pop-up window to edit the properties will appear, and after you
    close that window only the word where you clicked would be selected.

    for instance:

    we have the following:

    "This is a Link composed of several
    words and this is the rest of the text"

    and "Link composed of several words" would display with a blue underline
    in the editor.

    if i double click on the word "composed" the pop up window to edit the
    properties will appear, i close it, but only the word "composed" would
    be selected instead of the whole "Link composed of several words".

    can you please give me some pointers on how to make that after editing
    some element the whole element would be selected and not only the word i
    clicked on?


    Regards,
    And thanks a lot for your help.

    ------------------------------------------
    Posted to Phorum via PhorumMail
  • 2 Comments sorted by
  • Hi,

    Glad I helped you Smile.

    Please, take a look on the caretUpdate() function in the HtmlEditorKit
    class to see how we find document attributes under caret. When you know
    the position of the caret, you can go forward and backward through the
    document to find where those attributes will change. Of course, the
    places where document attributes change are actually the markers of
    your selection.

    Best,

    Nenad


    On Thursday 10 of June 2004 06:38, Daniel Gaytan wrote:
    > Nenad,
    > Thanks a lot for your function, it worked at the first try.
    > I dont want to abuse, but, can you give me some pointers on how to
    > correct a weird behavour in the applet?
    >
    > ill try to explain what is happening now:
    >
    > lets suppose we write the following:
    >
    > "This is a Link composed of several words and this is the rest of the
    > text"
    >
    > if we add an external link to "Link composed of several words"
    >
    > the final document when we save it would be:
    >
    > "This is a Link composed of
    > several words and this is the rest of the text"
    >
    > and "Link composed of several words" would display with a blue
    > underline in the editor.
    >
    > right?
    >
    > now, i have noticed that if you double click on any of the words
    > "Link", "composed", "of", "several", "words" or even on the spaces
    > between them. the pop-up window to edit the properties will appear,
    > and after you close that window only the word where you clicked would
    > be selected.
    >
    > for instance:
    >
    > we have the following:
    >
    > "This is a Link composed of
    > several words and this is the rest of the text"
    >
    > and "Link composed of several words" would display with a blue
    > underline in the editor.
    >
    > if i double click on the word "composed" the pop up window to edit
    > the properties will appear, i close it, but only the word "composed"
    > would be selected instead of the whole "Link composed of several
    > words".
    >
    > can you please give me some pointers on how to make that after
    > editing some element the whole element would be selected and not only
    > the word i clicked on?
    >
    >
    > Regards,
    > And thanks a lot for your help.

    ------------------------------------------
    Posted to Phorum via PhorumMail
  • Even better, instead to go forward and backward through the document,
    try to use Element.getStartOffset() and Element.getEndOffset()
    functions. Of course 'Element' is the one you've found under the caret.

    I didn't try it. It's just an idea.

    Nenad


    On Thursday 10 of June 2004 13:40, Nenad Pandzic wrote:
    > Hi,
    >
    > Glad I helped you Smile.
    >
    > Please, take a look on the caretUpdate() function in the
    > HtmlEditorKit class to see how we find document attributes under
    > caret. When you know the position of the caret, you can go forward
    > and backward through the document to find where those attributes will
    > change. Of course, the places where document attributes change are
    > actually the markers of your selection.
    >
    > Best,
    >
    > Nenad
    >
    > On Thursday 10 of June 2004 06:38, Daniel Gaytan wrote:
    > > Nenad,
    > > Thanks a lot for your function, it worked at the first try.
    > > I dont want to abuse, but, can you give me some pointers on how to
    > > correct a weird behavour in the applet?
    > >
    > > ill try to explain what is happening now:
    > >
    > > lets suppose we write the following:
    > >
    > > "This is a Link composed of several words and this is the rest of
    > > the text"
    > >
    > > if we add an external link to "Link composed of several words"
    > >
    > > the final document when we save it would be:
    > >
    > > "This is a Link composed of
    > > several words and this is the rest of the text"
    > >
    > > and "Link composed of several words" would display with a blue
    > > underline in the editor.
    > >
    > > right?
    > >
    > > now, i have noticed that if you double click on any of the words
    > > "Link", "composed", "of", "several", "words" or even on the spaces
    > > between them. the pop-up window to edit the properties will appear,
    > > and after you close that window only the word where you clicked
    > > would be selected.
    > >
    > > for instance:
    > >
    > > we have the following:
    > >
    > > "This is a Link composed of
    > > several words and this is the rest of the text"
    > >
    > > and "Link composed of several words" would display with a blue
    > > underline in the editor.
    > >
    > > if i double click on the word "composed" the pop up window to edit
    > > the properties will appear, i close it, but only the word
    > > "composed" would be selected instead of the whole "Link composed of
    > > several words".
    > >
    > > can you please give me some pointers on how to make that after
    > > editing some element the whole element would be selected and not
    > > only the word i clicked on?
    > >
    > >
    > > Regards,
    > > And thanks a lot for your help.

    ------------------------------------------
    Posted to Phorum via PhorumMail