[REBOL] Re: Field color change on error.
From: carl:cybercraft at: 18-Oct-2002 9:51
Hi Louis,
On 18-Oct-02, Louis A. Turk wrote:
> Hi Gabriele, Andrew, Anton, and Carl,
> Many thanks for all the help. I now have almost everything I
> want. Compositing everything all of you said I came up with this:
> lab "email:" email: field [
> either email? attempt [load value] [
> face/colors: reduce [white white]
> set-font face color black
> set-font face style 'normal ; <====<<
> DOESN'T WORK
> ][
> replace value value "<<<<< INVALID EMAIL
>>>>>> "
> face/colors: reduce [red red]
> set-font face color yellow
> set-font face style 'bold
> show face
> ]
> ] return
> When an invalid email is entered, this sets the background color to
> red, and the font to bold yellow, and prints "<<<<< INVALID EMAIL
>>>>>> " exactly as I want. Then when a valid email is entered the
> colors are set back as they were.
> However, the font style remains bold. How do I set it back to
> normal?
A font's style can be either none, 'bold, 'italic, 'underline or a
block with the styles in. (Or an empty block). However, neither of
these seem to work...
set-font face style none
set-font face style 'none
so you'll have to use a method other than set-font. ie...
face/font/style: none
which is probably faster anyway, not to mention shorter.
> Also, why does this result in an error message instead of false?
>>> email? kkkkk
> ** Script Error: kkkkk has no value
> ** Near: email? kkkkk
>>>
> That just doesn't seem right to me in this particular context. I
> know that kkkkk is an unset word, but all you want to know with
> email? is the validity of the entry. It seems to me that email?
> value by itself should do what email? attempt [load value] does.
'kkkkk is evaluated before its result are returned to email?, so the
error occurs before email? gets 'kkkkk. You could perhaps use
something like...
>> email? first [kkkkk]
== false
>> email? first [[k--kkk]]
== true
or if the word's a, err, word's value...
>> w: 'kkkkk
== kkkkk
>> email? w
== false
>> w: ['k--kkk]
== ['k--kkk]
>> email? w
== true
PS. Oh, you've had some replies already. (: Gabriele suggested
this...
set-font face style none
yet it doesn't work for me...
>> view layout [field "aaa" [set-font face style none show face]]
** Script Error: Invalid argument: none
** Where: action
** Near: show face
Another beta enhancemant I assume?
--
Carl Read