Can one use a text-list for selecting items?

Discussion in 'Rebol' started by swhite, Mar 18, 2011.

  1. swhite

    swhite Member

    I want to display a bunch of stuff, and let a person select one of them. I am looking through the documentation and it looks like a text-list might be the item for that. I see how to fill a text-list, and one can click the mouse on an item in a text-list, but can one then get the item that was selected? I wrote a demo based on the documentation. I am looking for the line of code to reference the item selected in the text list.

    Thank you.

    REBOL [
    ]

    SHOW-SELECTED: does [
    ;; ;; How do I, or can I, get the item in the text-list
    ;; ;; that was selected?
    SELECTED-ITEM/text: FILE-NAMES/value ;; this does not work
    ;; ;;
    show SELECTED-ITEM
    ]

    view layout [
    vh2 "File List:"
    FILE-NAMES: text-list data read %.
    button "Show selected" [SHOW-SELECTED]
    SELECTED-ITEM: text ""
    ]
  2. Sunanda

    Sunanda New Member

    The selected lines are in FILE-NAMES/picked. Try this:
    Code:
    REBOL []
    
    SHOW-SELECTED: does [
    SELECTED-ITEM/text: mold FILE-NAMES/picked ;; this does work, but might need soem formatting
    show SELECTED-ITEM
    ]
    
    unview/all
    view layout [
    vh2 "File List:"
    FILE-NAMES: text-list data read %.
    button "Show selected" [SHOW-SELECTED]
    SELECTED-ITEM:  text 200x200  ""
    ] 
    Note that to pick multiple lines, you have to hold down the CTRL key and click.
  3. MaxV

    MaxV Member

    there is the "picked" refineiment, see this:
    Code:
     view layout [ 
      a: text-list "Red" "Green" "Blue"  [print a/picked]
      ]
    

Share This Page