Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Altering the feel of fields.

From: carl:cybercraft at: 8-Jun-2002 10:53

On 06-Jun-02, Cyphre wrote:
> Hi Carl, > I'm not sure if this little hack will meet your needs: > view layout [field [print "x"] with [feel/detect: func [f e][if all > [e/type = 'down not-equal? f system/view/focal-face] [do-face f > none] e]]] > regards, > Cyphre
Thanks Cyphre, that put me on the right track. There were a couple of problems with it though. Firstly, 'with affected all fields, not just the one where it's used. Well, at least with how you used it. Is there any way to prevent this? I couldn'd find any decent description of how to use 'with amongst the docs I looked at. I solved this though by creating a field style with stylize and then adding your feel/detect function outside of the stylize block. But there was still a problem in that while it detected fields becoming active when you clicked on them it didn't notice when you entered from another field when pressing Return. But as I said, you put me on the right track and I've got it to behave to my liking by using a modified version of field's default feel/redraw, instead of using detect. The default redraw looks like this... redraw: func [face act pos][ if all [in face 'colors block? face/colors] [ face/color: pick face/colors face <> view*/focal-face ] ] and here's my modified version used in an example... ---8<--- rebol [] new-styles: stylize [ new-field: field ] new-styles/new-field/feel: make new-styles/new-field/feel [ redraw: func [face act pos][ if all [in face 'colors block? face/colors] [ face/color: pick face/colors either face <> system/view/focal-face [ true ][ if face/color = face/colors/1 [do-face face none] false ] ] ] ] view layout [ styles new-styles across field "Normal Field 1" [print "Normal 1"] field "Normal Field 2" [print "Normal 2"] return new-field "New Field 1" [print "New-field 1"] new-field "New Field 2" [print "New-field 2"] ] ---8<--- Could be of use to others, as obviously the "do-face face none" could be changed to anything you want to happen when a field becomes active. Thanks again, Carl.
>> Hi all, >> How would you get a field to evaluate its block when the field is >> activated as well as when you press Enter? ie, so "x" here... >> view layout [field [print "x"]] >> is printed when you first click on the field. I've spent a lot of >> time playing with feel in an attempt to get this working but >> without >> any luck... >> -- >> Carl Read
-- Carl Read