我正在尝试使用用户输入2个数字的代码,然后点击计算按钮,应显示答案。还有用于清除字段和退出的按钮。
REBOL[]
fields: [f-ht f-wt ans]
reset-fields: does [
unfocus
f-ht/text: " " ; Changing this to "ENTER NUMBER HERE" does not help
f-wt/text: " "
focus f-ht
]
oncalc: does [
ans/text: (to integer! f-wt/text) / ((100 * to integer! f-ht/text) * (100 * to integer! f-ht/text))
show fields
]
lo: layout [
style tx label 200x24 center
style fld field 200x24 center
style btn button 200x24 center
tx "First Number:"
f-ht: fld
tx "Second Number:"
f-wt: fld
btn "Calculate" [oncalc]
ans: tx "Answer"
btn "Clear" [reset-fields show fields] ; NOT WORKING- NOTHING HAPPENS
btn "Exit" escape [unview/only lo]
]
reset-fields
view center-face lo
GUI显示正常。但是,存在以下问题:
On clear button clicking, nothing is happening.
GUI没有变化,也没有报告错误。问题在哪里,如何解决?谢谢你的帮助。
答案 0 :(得分:1)
清除字段而不是设置为新字符串
reset-fields: does [
unfocus
clear f-ht/text
clear f-wt/text
focus f-ht
]