在下面的原型测试代码中,我正在尝试创建一个比较两个字段的比较系统,并根据它们是否相等来对它们进行着色。
comparecolors: [
either answer-user/text = answer-correct/text [
answer-user/font/color: green
answer-correct/font/color: green
show answer-user
show answer-correct
][
answer-user/font/color: red
answer-correct/font/color: black
show answer-user
show answer-correct
]
]
view layout [
answer: field [
answer-user/text: copy answer/text
do comparecolors
show answer
focus answer
show answer-user
]
label "Compare"
answer-user: info
answer-correct: info
across
text-list "Hello" "Goodbye" "Boy" "Girl" "Soldier" [
answer-correct/text: copy value
do comparecolors
show answer-correct
]
]
我遇到的一些问题:
答案 0 :(得分:4)
每当您在仅更改一个属性时看到多个字段受到影响时,这意味着VID已进行优化,以便所有这些字段共享相同的数据结构,并且在此中使用相同的字体结构。因此,我们需要强制VID分配一个新的字体结构,如下所示:
change-colors: func [ user [object!] correct [object!]
/local u c
][
set [ u c ]
either user/text = correct/text [
[ green green ]
][
[ red black ]
]
user/font/color: get u
correct/font/color: get c
show [ user correct ]
]
view layout [
answer: field [
answer-user/text: copy answer/text
change-colors answer-user answer-correct
focus answer
] font-color black
label "Compare"
answer-user: info font-color black
answer-correct: info font-color black
across
text-list "Hello" "Goodbye" "Boy" "Girl" "Soldier" [
answer-correct/text: copy value
change-colors answer-user answer-correct
]
]