Altering the feel of fields.
[1/5] from: carl:cybercraft at: 5-Jun-2002 20:26
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
[2/5] from: cyphre::seznam::cz at: 5-Jun-2002 17:03
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
[3/5] from: ammon:rcslv at: 5-Jun-2002 20:55
Hi, I wasn't paying enough attention to notice if this got a proper answer or not, but here are my questions/suggestions. Have you looked at the RT HowTo on event handling? If not, here is the URL http://Rebol.com/how-to/feel.html notice that there are some other very helpful HowTo's that are available from http://Rebol.com/how-to.html Now that that is taken care of, have you tried something like: view layout [field [print "x"] #"^M"] HTH Ammon A short time ago, Carl Read, sent an email stating:
[4/5] 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:
<<quoted lines omitted: 3>>> 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
<<quoted lines omitted: 6>>>> -- >> Carl Read
-- Carl Read
[5/5] from: carl:cybercraft at: 8-Jun-2002 11:17
On 06-Jun-02, Ammon Johnson wrote:
> Hi, > I wasn't paying enough attention to notice if this got a proper
<<quoted lines omitted: 7>>> HTH > Ammon
Thanks Ammon, but as you can see by my post made just a minute ago, I did receive a good answer. I know of the how-tos, but they wouldn't have helped me enough without Cyphre's suggestion. I'd tried modified feel/redraw's already, but they failed because I didn't know view* meant "system/view". Also, I didn't know "do-face face none" was what was required to evaluate a style's block. Neither of those bits of information will be found in the Feel how-to, or, I suspect, any View/VID docs supplied by RT. Yes, in case you're wondering, I've spent a awful lot of time getting this simple-thing-that-should-be-simple thing to work. (;
> A short time ago, Carl Read, sent an email stating: >> Hi all,
<<quoted lines omitted: 4>>>> time playing with feel in an attempt to get this working but >> without any luck...
-- Carl Read
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted