Text item bug or feature?

Discussion in 'Rebol' started by swhite, Oct 12, 2011.

  1. swhite

    swhite Member

    The following script shows something I do not understand. It seems that if I have, on a VID screen, a "text" item, I can not change its value unless it had some value to start with. I have gotten around the problem by putting default values in text items, so I am not having a "problem," but it's not quite the way I imagined things should work. Is there a bug, or am I imagining wrong?

    In the following script, if you click the "show text" button, it will refresh the text of three text items, and then show them, but the only one that will show anything is TEXT-3, the one that had some default text there in the first place.

    Thank you.

    REBOL [
    Title: "Test text item"
    ]

    SHOW-TEXT: does [
    TEXT-1/text: "text one"
    TEXT-2/text: "text two"
    TEXT-3/text: "text three"
    show [
    TEXT-1
    TEXT-2
    TEXT-3
    ]
    ]

    view layout [
    across
    label "TEXT-1"
    TEXT-1: text ""
    return
    label "TEXT-2"
    TEXT-2: text " "
    return
    label "TEXT-3"
    TEXT-3: text "default text"
    return
    button "Show text" [SHOW-TEXT]
    ]
  2. Graham

    Graham Developer Staff Member

    It's a feature. Try this instead if you want to see your changes

    Code:
    view layout [
       across
       label "TEXT-1"
       TEXT-1: text "" 40
       return
       label "TEXT-2"
       TEXT-2: text "          "
       return
       label "TEXT-3"
       TEXT-3: text "default text"
       return
       button "Show text" [SHOW-TEXT]
    ]
    
  3. MaxV

    MaxV Member

    Yes, text item is not flexible. When you decide the length, it will remain forever.
    So a " " can't show quite anything! Moreover there is extra spaces suppression in text string, so there is no differences between
    Code:
     ""
    and
    Code:
     "               "
    The most elegant solution is to provide the maximum length like:
    Code:
     TEXT-1: text "" 40 

Share This Page