JanDeRuiter:
Thanks Johan,
It seems to work. Is there a specific reason for this behaviour?
I don’t seem to understand the difference between a solutionModel component and a runtime element.
because runtime there parts are (swing or web)container objects and object positions inside a container are relative to there parent container.
A SolutionModel form just has elements. Parts are there not noting more as just a description where the part starts…
So all elements of a form are just on that form, relative to the form, not to a part which is not really a thing (a ui element) in the solution model.
JanDeRuiter:
Perhaps someone can explain this to me based on my example?
To keep it readable, this is the principle of the code we wrote to get or set properties from/to an element object.
1. Getting properties
var _form = solutionModel.getForm(“myForm”);
var _field = _form.getField(“myField”);
var posY = _field.y;
With this you get the solution model fields position relative to the form.
This has nothing to do with Runtime/UI position.
JanDeRuiter:
2. Recreation and setting properties
var _form = solutionModel.newForm(‘myForm’, ‘myServer’, ‘myTable’, ‘myStyleName’, false, 800, 600)
var _field = _form.newField(‘myField’,1,200,200,200,30);
_field.y = 100;
var posY = _field.y;
I would expect that: _field.y = 100; or var posY = field.y; would work consistently.
which one of the 2 above is a solutionModel object and which one is a runtime object? (Both are created using solutionModel.)
and that is consistent…
because BOTH are solutionModel.
if you would do after you created that newForm ‘myForm’ and the new field (and you added a part)
and then did:
forms.myForm.elements.myField.getLocationY();
You would get, if the myfield sits in a body part on a form that also has a title part or something like that, a Y position relative to that part so you wouldnt get 100 (the value you set with _field.y = 100)
but you would get 80 (if the title part was 20 pixels height)
But if you ask
forms.myForm.elements.myField.getAbsoluteFormLocationY();
you would get 100 because that the absolute form location is the same as the solution model element location.
JanDeRuiter:
For all object properties, except this one, we can use the same property instruction to get or to set an object property. So we could have minimal code to save and build a complete form including all possible properties in a data driven manner.
It’s a pity that we now have to break out the routine to get the Y position in a different way, i.e. forms[_form.name].elements[_field.name].getAbsoluteFormLocationY();. That’s just the 2 cents opinion of a code minimalist ![Wink :wink:]()
I’ll make a case for the object-stuck problem.
You need to have 2 things, if you use for example the client design you need to have the absoluteformlocationy because if you want to set the position of a runtime element back into the solution model element you need this value
But if you just want to move the runtime/ui element 10 pixels below the current position you would use var y = forms.formname.elements.elementname.getLocationY() + 10;
if you there would use the absolute it would jump way more then 10 pixels… (if there is a part above it)
So the only time you need to use getAbsoluteFormLocationY() is when you want to go from runtime/ui to solution model to store the current ui position.