2

I've got a VID list in Rebol2 and I want to make one of the columns some kind of menu from which I can select a value from a set of choices. The code that I'm using was based off of the list-widget-example.r. The set of choices is dynamic.

I tried using "choice" and "rotary" with a static set of choices, but that fared poorly. Using "choice" always used the first value and "rotary" popped open a black window.

Scott W
  • 41
  • 3
  • If I put a request-list in the engage function for the column it pops up a menu, but the result of the query is not being propagated back into the list . The statement in the engage function looks like: `col2 [ f/text: request-list {Select choice} candidates show li]` where li is the list object. – Scott W Mar 20 '15 at 19:05

2 Answers2

2

Here is a trimmed down version of @AntonRolls code that explicitly answers the question. It is "a fairly rudimentary example which shows how to use a CHOICE menu in a VID LIST."

members: [ {Gandalf} {Bilbo} {Frodo} ]
db: [
    ["1" "question 1 " "default1"]
    ["2" "question 2"  ""]
    ["3" "question 3"  "default3"]
]
view out: layout [
    mylist: list 450x240 [
        across 
        t1: text 50x20
        t2: text 200x20 para [wrap?: true] 
        t3: text 200x20 effect [merge luma 10] font [] [
        ][
            ; alt-action (right-click action)
            use [row][
                if row: face/user-data [ ; face knows index
                    choose/window/offset members func [face value][
                        poke db/:row 3 face/text
                    ] out (
                        mylist/offset + (t3/offset * 1x0) 
                        + (row - 1 * t3/size * 0x1)
                    )
                ]
            ]
        ]
    ] supply [
        either count <= length? db [
            face/user-data: count ; store row index
            switch index [
                1 [face/text: db/:count/1]
                2 [face/text: db/:count/2]
                3 [face/text: db/:count/3]
            ]
        ][
            face/user-data: face/text: none
        ]
    ]
Scott W
  • 41
  • 3
  • Nice job trimming! I did a little editing to fit it in the margins and link Anton's code. Please feel free to add your remarks to [any existing Rebol question](http://stackoverflow.com/questions/tagged/rebol)--even one already answered. It only takes 20 points to [join in chat](http://rebolsource.net/go/chat-faq)... – HostileFork says dont trust SE Mar 24 '15 at 15:01
0

This is a fairly rudimentary example which shows how to use a CHOICE menu in a VID LIST.

https://s3-ap-southeast-1.amazonaws.com/antonrolls/rebol/gui/iterated/demo-list-of-texts-with-context-menu.r

(I pasted the code for completeness, but I had not wholly read other answers, sorry. Please, ignore this edit. My apologies for the mess/noise/disturbance.)

Pierre
  • 530
  • 5
  • 13
  • 1
    Welcome to StackOverflow, and nice of you to share your code! Don't be discouraged by getting an initial downvote...but link-only answers are not considered to be a good fit for the format. I looked to see if your example was short enough to paste, but it's a bit long and seems to do more than just what was asked. Perhaps you could try the EDIT button to amend with a simpler example that focuses specifically on the question asked? – HostileFork says dont trust SE Mar 21 '15 at 13:35
  • Excuse me, but I've noticed that I've described the example not perfectly accurately; it should read: "This .. example .. shows how to pop open a context menu from a VID LIST, using the CHOOSE function." (It does not use a VID CHOICE style – Anton Rolls Mar 25 '15 at 10:14