Selecting text so it STAYS selected.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Razzbar

    Selecting text so it STAYS selected.

    I have a textarea and some buttons. The buttons apply functions to
    the text the user selects, i.e. the good old "wrap with a tag"
    thing we all have seen in 100 different editors.

    Trouble is, when I click the button, the selected text gets
    unselected. Select some text in the textbox and click -anywhere-
    and the text unselects.

    I want that text to stay selected!

    Don't you?

    How?
  • Ivo

    #2
    Re: Selecting text so it STAYS selected.

    "Razzbar" wrote[color=blue]
    > I have a textarea and some buttons. The buttons apply functions to
    > the text the user selects, i.e. the good old "wrap with a tag"
    > thing we all have seen in 100 different editors.
    >
    > Trouble is, when I click the button, the selected text gets
    > unselected. Select some text in the textbox and click -anywhere-
    > and the text unselects.
    > I want that text to stay selected![/color]

    Try calling the function behind that button "onmousedow n" instead of
    "onclick", as seen in 100 different editors.
    HTH
    Ivo


    Comment

    • Razzbar

      #3
      Re: Selecting text so it STAYS selected.

      "Ivo" <no@thank.you > wrote in message news:<408fd24a$ 0$54140$1b2cd16 7@news.wanadoo. nl>...[color=blue]
      > "Razzbar" wrote[color=green]
      > > I have a textarea and some buttons. The buttons apply functions to
      > > the text the user selects, i.e. the good old "wrap with a tag"
      > > thing we all have seen in 100 different editors.
      > >
      > > Trouble is, when I click the button, the selected text gets
      > > unselected. Select some text in the textbox and click -anywhere-
      > > and the text unselects.
      > > I want that text to stay selected![/color]
      >
      > Try calling the function behind that button "onmousedow n" instead of
      > "onclick", as seen in 100 different editors.
      > HTH
      > Ivo[/color]

      Good, good... Now, what if I want to select some text like for a
      search and replace within the selection? I select me text, then
      I go down to an input field where I wants to put in the terms
      of the s&r... click -anywhere- outside of the selected area,
      and the selection unselects. Drat.

      Comment

      • Ivo

        #4
        Re: Selecting text so it STAYS selected.

        "Razzbar" wrote[color=blue]
        > "Ivo" wrote[color=green]
        > > "Razzbar" wrote[color=darkred]
        > > > I have a textarea and some buttons. The buttons apply functions to
        > > > the text the user selects, i.e. the good old "wrap with a tag"
        > > > thing we all have seen in 100 different editors.
        > > >
        > > > Trouble is, when I click the button, the selected text gets
        > > > unselected. Select some text in the textbox and click -anywhere-
        > > > and the text unselects.
        > > > I want that text to stay selected![/color]
        > >
        > > Try calling the function behind that button "onmousedow n" instead of
        > > "onclick", as seen in 100 different editors.
        > > HTH
        > > Ivo[/color]
        >
        > Good, good... Now, what if I want to select some text like for a
        > search and replace within the selection? I select me text, then
        > I go down to an input field where I wants to put in the terms
        > of the s&r... click -anywhere- outside of the selected area,
        > and the selection unselects. Drat.[/color]

        Even clicking *in* the selected area unselects it. It 's the very nature of
        selections. The flashing cursor in the search box indicating where the next
        typed letter will appear is sort of a selection itself (with length 0) and
        there can only be one selection at a page at any time.
        Generally I think such behaviour should be left alone so users know what to
        expect and don't get confused. In your case, you could try copying the
        selected text to a separate (hidden) area so it is remembered while typing,
        or fiddling with its background and text-colour to make it *appear*
        selected. This would probably best be done "onmouseup" .
        HTH
        Ivo


        Comment

        • Ivo

          #5
          Re: Selecting text so it STAYS selected.

          "Ivo" wrote[color=blue]
          > "Razzbar" wrote[color=green]
          > > "Ivo" wrote[color=darkred]
          > > > "Razzbar" wrote
          > > > > I have a textarea and some buttons. The buttons apply functions to
          > > > > the text the user selects, i.e. the good old "wrap with a tag"
          > > > > thing we all have seen in 100 different editors.
          > > > >
          > > > > Trouble is, when I click the button, the selected text gets
          > > > > unselected. Select some text in the textbox and click -anywhere-
          > > > > and the text unselects.
          > > > > I want that text to stay selected!
          > > >
          > > > Try calling the function behind that button "onmousedow n" instead of
          > > > "onclick", as seen in 100 different editors.
          > > > HTH
          > > > Ivo[/color]
          > >
          > > Good, good... Now, what if I want to select some text like for a
          > > search and replace within the selection? I select me text, then
          > > I go down to an input field where I wants to put in the terms
          > > of the s&r... click -anywhere- outside of the selected area,
          > > and the selection unselects. Drat.[/color][/color]

          On second thoughts, after reading your question a bit more slowly, I think
          the best approach is the easiest: first enter the search&replacem ent
          strings, and then select the text. This will make perfect sense to your
          users if you label your buttons properly.
          Ivo
          [color=blue]
          > Even clicking *in* the selected area unselects it. It 's the very nature[/color]
          of[color=blue]
          > selections. The flashing cursor in the search box indicating where the[/color]
          next[color=blue]
          > typed letter will appear is sort of a selection itself (with length 0) and
          > there can only be one selection at a page at any time.
          > Generally I think such behaviour should be left alone so users know what[/color]
          to[color=blue]
          > expect and don't get confused. In your case, you could try copying the
          > selected text to a separate (hidden) area so it is remembered while[/color]
          typing,[color=blue]
          > or fiddling with its background and text-colour to make it *appear*
          > selected. This would probably best be done "onmouseup" .[/color]


          Comment

          • Razzbar

            #6
            Re: Selecting text so it STAYS selected.

            "Ivo" <no@thank.you > wrote in message news:<4090d0c4$ 0$67519$ee9da40 f@news.wanadoo. nl>...[color=blue]
            > "Razzbar" wrote[/color]
            [color=blue][color=green][color=darkred]
            > > > > I want that text to stay selected![/color][/color][/color]
            [color=blue]
            > Even clicking *in* the selected area unselects it. It 's the very nature of
            > selections. The flashing cursor in the search box indicating where the next
            > typed letter will appear is sort of a selection itself (with length 0) and
            > there can only be one selection at a page at any time.[/color]

            Close. There can be only one selection per -client area- i.e. a textarea,
            or an input field... etc. But if there are two textareas in a window, you
            should be able to make a selection in both. Should be able to.
            [color=blue]
            > Generally I think such behaviour should be left alone so users know what to
            > expect and don't get confused.[/color]

            Confusion is what I'm trying to prevent. It's more intuitive to select
            the area, then enter the search and replacement, then click the button,
            than enter, select, click. And the confusion I'm getting is that when
            I do it the latter way, my selection disappears... "where am I?".
            [color=blue]
            > In your case, you could try copying the
            > selected text to a separate (hidden) area so it is remembered while typing,
            > or fiddling with its background and text-colour to make it *appear*
            > selected. This would probably best be done "onmouseup" .[/color]

            That works, but it makes the textarea "blink". Guess I can live with
            that.

            Thing is, I've researched this before, and seem to recall finding
            discussions on this subject, and that there was some attribute that
            could be set. That's what I'm looking for. Some attribute you can
            set that tells the selection to stay selected when the user clicks
            outside the client area.

            But I think it's still gonna have to blink. User selects, program
            grabs a copy of the selection, applys the function to the copy, then
            slaps the processed copy into the selection area. Oh well. It's ugly,
            but it works. I'm not a web designer, I'm a web programmer. If I
            were a web designer, that would be unacceptable.

            Comment

            • rh

              #7
              Re: Selecting text so it STAYS selected.

              glakk@potatorad io.f2s.com (Razzbar) wrote:
              <snip>[color=blue]
              > Thing is, I've researched this before, and seem to recall finding
              > discussions on this subject, and that there was some attribute that
              > could be set. That's what I'm looking for. Some attribute you can
              > set that tells the selection to stay selected when the user clicks
              > outside the client area.
              >[/color]

              Possibly you are recalling - unselectable="o n" - which allows an
              action, e.g., response to a mouseclick, to be initiated on an element
              without removing focus from an existing selection.

              I believe this is an IE only feature which was added by MS to provide
              support for WSIWYG editors (originally based on MSHTML).

              ../rh

              Comment

              • Ivo

                #8
                Re: Selecting text so it STAYS selected.

                "Razzbar" wrote[color=blue]
                > "Ivo" wrote[color=green]
                > > there can only be one selection at a page at any time.[/color]
                >
                > Close. There can be only one selection per -client area- i.e. a textarea,
                > or an input field... etc. But if there are two textareas in a window, you
                > should be able to make a selection in both. Should be able to.[/color]

                Sais who? I tried in Mozilla and IE, and both allow one selection on a page
                and one only. I thought at least IE would remember (but invisibly) a
                selection in a framed page while another frame has focus so multiple
                selections in one window would be possible with a frameset, but I just tried
                and when focusing the next frame or textarea or similar either by clicking
                or tabbing, the earlier selection is lost. Tabbing back does not get it
                back. Simple.
                IF I had two textarea's on a page with a selection in both and I started
                typing, where would my letters appear?
                [color=blue]
                > It's more intuitive to select
                > the area, then enter the search and replacement, then click the button,
                > than enter, select, click.[/color]

                I 'm not convinced. At first sight, this is probably true, but people can
                get used to the most crazy stuff as long as they 're not worried about the
                craze or just do it often enough.
                [color=blue][color=green]
                > > In your case, you could try copying the
                > > selected text to a separate (hidden) area so it is remembered while[/color][/color]
                typing,[color=blue][color=green]
                > > or fiddling with its background and text-colour to make it *appear*
                > > selected. This would probably best be done "onmouseup" .[/color]
                >
                > That works, but it makes the textarea "blink". Guess I can live with
                > that.[/color]

                Blink? Live with that? Guess that reaffirms my earlier statement about
                getting used to things.
                [color=blue]
                > Thing is, I've researched this before, and seem to recall finding
                > discussions on this subject, and that there was some attribute that
                > could be set. That's what I'm looking for. Some attribute you can
                > set that tells the selection to stay selected when the user clicks
                > outside the client area.[/color]

                Such attribute would be new to me.
                [color=blue]
                > But I think it's still gonna have to blink. User selects, program
                > grabs a copy of the selection, applys the function to the copy, then
                > slaps the processed copy into the selection area. Oh well. It's ugly,
                > but it works. I'm not a web designer, I'm a web programmer. If I
                > were a web designer, that would be unacceptable.[/color]

                That 's no excuse! Please think about what you are saying. Don't hide behind
                your code, you have clients who are real people. You give the profession a
                bad name this way. The designer and programmer and any related profession -
                because the end users don't know or care to know who did what.
                Ivo


                Comment

                Working...