如何将菜单放入 rebol 列表 (VID)?
How do I put a menu in a rebol list (VID)?
我在 Rebol2 中有一个 VID 列表,我想使其中一列成为某种菜单,从中我可以 select 从一组选项中选择一个值。我使用的代码基于 list-widget-example.r。选择集是动态的。
我尝试将 "choice" 和 "rotary" 与一组静态选项一起使用,但效果不佳。使用 "choice" 总是使用第一个值并且 "rotary" 弹出一个黑色 window.
这是一个相当初级的示例,展示了如何使用 CHOICE 菜单
在视频列表中。
(为了完整起见,我粘贴了代码,但我没有完全阅读其他答案,抱歉。请忽略此编辑。对于 mess/noise/disturbance,我深表歉意。)
这里是 @AntonRolls code 的精简版,明确回答了这个问题。即"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
]
]
我在 Rebol2 中有一个 VID 列表,我想使其中一列成为某种菜单,从中我可以 select 从一组选项中选择一个值。我使用的代码基于 list-widget-example.r。选择集是动态的。
我尝试将 "choice" 和 "rotary" 与一组静态选项一起使用,但效果不佳。使用 "choice" 总是使用第一个值并且 "rotary" 弹出一个黑色 window.
这是一个相当初级的示例,展示了如何使用 CHOICE 菜单 在视频列表中。
(为了完整起见,我粘贴了代码,但我没有完全阅读其他答案,抱歉。请忽略此编辑。对于 mess/noise/disturbance,我深表歉意。)
这里是 @AntonRolls code 的精简版,明确回答了这个问题。即"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
]
]