Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: field in VID?
Pages: [1] Print
Author Topic: field in VID?  (Read 621 times)
SituAgent
Newbie
*
Offline Offline

Posts: 7


View Profile
field in VID?
« on: December 01, 2006, 09:34:28 AM »

How do you bind the input of a VID field to a word (variable)?  As an example, for:

      style lab label 150 right
      lab "Length:" field 40x20 form 10

Would you write:

      len:  lab "Length:" field 40x20 form 10

I doubt it, but I haven't seen an example of assignment yet.

      Thanks.

David
Logged
Sunanda
Full Member
***
Offline Offline

Posts: 113


View Profile
Re: field in VID?
« Reply #1 on: December 01, 2006, 04:03:59 PM »

Pretty close -- try this:

label "Length:" len: field 40x20 form 10

Note that the field is assigned to your LEN word. The field is an object with various words in it. The value will be in the /text word. Try this, and tab out of the field to trigger the print:

 view layout [label "Length:" len: field 40x20 form 10 [print len/text]]

Logged
Graham
Full Member
***
Offline Offline

Posts: 113


View Profile
Re: field in VID?
« Reply #2 on: December 01, 2006, 04:48:42 PM »

Since the action block automatically acquires the face object as 'face, you can also do this

view layout [label "Length:" field 40 "10" [print face/text]]
Logged

henrikmk
Jr. Member
**
Offline Offline

Posts: 50


View Profile
Re: field in VID?
« Reply #3 on: December 08, 2006, 06:10:38 AM »

Another sometimes useful but less beginnerish way is to create the string first and use that in the layout, using the fact that layout binds variables with series! contents directly to the face objects:

Quote

t: ""
view layout [f: field t]


't is then bound directly to 'face/text for the field (so you don't need to dig into the face object to get the text out) and this automatically updates the contents of 't with the contents of the text field and vice versa as long as 't is kept as a string and as long as you don't reassign 't to a new string. If you do that, you'll lose the binding. The binding is created during the layout phase.

This is a good exercize in how simple bindings work, but it also saves a tiny bit of hassle with updating a variable manually with text field contents, especially if you'll need to store the contents of the variable somewhere else quickly. When you have many text fields, that "tiny bit" turns into "a lot". :-)

You can manipulate 't using series manipulators, such as 'next, 'back, 'head, 'clear, 'insert, 'append and so forth. To update the variable and the face text, you can use something like:

Quote

insert clear t "some text"
show f


To see field updates, use a 'show.

Bindings work only on series! types, so you can't use it to update the size or a number attribute for the field. There are also other costs, for example 'set-face no longer works correctly, because it reassigns a new string to the face.
Logged
SituAgent
Newbie
*
Offline Offline

Posts: 7


View Profile
Re: field in VID?
« Reply #4 on: December 10, 2006, 12:28:08 AM »

     Sorry to be slow responding; I've been immersed in work.  Thanks for the suggestions, all three of them are helpful. 

     What does the user need to do to override the default value?  Type in a new value and hit return?  Are the values (default or replacement) available to subsequent functions?

     Thanks again.
Logged
Sunanda
Full Member
***
Offline Offline

Posts: 113


View Profile
Re: field in VID?
« Reply #5 on: December 10, 2006, 05:25:42 AM »

Hitting return or tabbing out of the field wil change the value in face/text. And that is immediately available to other functions.
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
Re: field in VID?
« Reply #6 on: December 11, 2006, 04:31:12 AM »

Actually, face/text is always up to date. However the action is only called on return or tabbing (or unfocusing).
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: field in VID?
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 02, 2008, 07:47:44 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2311 Posts in 595 Topics by 4142 Members
Latest Member: FoxxxTrott

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc