TOPIC: FormControl and xstretch
#1709
FormControl and xstretch 8 Months, 2 Weeks ago
I'm having problem to get form control work as I understood it should work.

Example:

Field_anamedfield
Field_string
{
Prompt: 'AField'
Control: (Field)
}

MyFormControl
Controller
{
Controls: #(Form xstretch:1
(anamedfield xstretch:1 group:0) nl
nL
(Field name:'AName' xstretch:1 group:0)

)
}

With teh above example the field "AName" (using FieldControl directly) get's strettched as expected but the field "anamedfield" (using FieldControl indirectly) doesn't.

Reading the Suneidos Manual I understood that booth should be stretched, I'm missing something here ?

Thanks in advance for any help ?
 
 
Last Edit: 2009/12/07 14:20 By mingodad.
 
#1710
Re:FormControl and xstretch 8 Months, 2 Weeks ago
It took me a few minutes to figure that out.

When you specify a field just by name it gets converted to a PairControl with the prompt and control from the Field_ definition.

FormControl specifically uses the group: member, but other members are discarded. (in Control.Construct)

Even if the xstretch was copied to the Pair it would not work because the control within the Pair would still not be stretchable.

You need to put the xstretch on the control in the Field_ definition.

We might be able to change Control.Construct to copy xstretch (and presumably other things like xmin and ymin) to the control from the Field_ definition. I tried this and it works, but I am worried that it might break existing code. If you want to try it, here is the change:

Code:

else if (String?(x[0]) and x[0] =~ "^[_a-z]")
    {
c = x
    name = x[0]
    x = Datadict(name).Control.Copy()
    x.name = name;
x.xstretch = c.xstretch

 
 
andrew
 
#1711
Re:FormControl and xstretch 8 Months, 2 Weeks ago
There is a problem when thre is no xstretch param with the sugested code, see modified one bellow:


Sorry too soon it doesn't work !!!!

Code:


else if (String?(x[0]) and x[0] =~ "^[_a-z]")
{
c = x
name = x[0]
x = Datadict(name).Control.Copy()
x.name = name
if c.Has?(#xstretch) //With this test it works
x.xstretch = c.xstretch




On GridControl the same problem happen:

Window(#(Grid xstretch:1 (
( (Static Name) (Center (Static Score) xstretch:1) )
( (Static Joe) (Number xstretch:1) )
( (Static Sue) (Number xstretch:1) )
( (Static Bob) (Number xstretch:1) )
))
)
 
 
Last Edit: 2009/12/07 17:32 By mingodad.
 
#1712
Re:FormControl and xstretch 8 Months, 2 Weeks ago
The test:

if c.Has?(#xstretch)
x.stretch = c.xstretch

Was supposed to correct it but it doesn' work !

I found the problem, it should be:

if c.Member?(#xstretch)
x.stretch = c.xstretch
 
 
Last Edit: 2009/12/07 17:43 By mingodad.
 
#1713
Re:FormControl and xstretch 8 Months, 2 Weeks ago
Sorry - I only tested with your example.

You show x.stretch - I assume that is a typo - should be x.xstretch

Grid may not handle stretch
 
 
andrew