Rebol text fields - checking values and changing colors -


in following prototype test code, i'm trying create comparison system compares 2 fields, , colors them depending on whether equal or not.

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         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         comparecolors         show answer-correct     ] ] 

some problems having:

  • the green color affecting fields instead of ones specifying.
  • the red color not working when 2 fields not equal.
  • the system not check none! value (i know not written in above code, tried ways didn't work, don't know how go it).

whenever see multiple fields affected when change attribute of one, means vid has made optimization fields sharing same data structure, , in same font structure. so, need force vid allocate new font structure this:

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: u     correct/font/color: 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     ] ] 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -