Achoring to Centre?

Hi Folks

I have a number of elements I need to have centred on my forms even when the form is re-sized. Also I need to anchor a group of elements, so couple of questions:

Q: What’s the simplest way of ensuring elements stay centred on a form (horizontally and vertically)?
Q: Is it possible to anchor a group of elements?

Appreciated Feedback

Ian

You can only anchor to the sides, not to the center.

But to do what you want, you should use the onResize event. In the onResize method you can get the width and height of your form and then set the elements to the correct position.

Joas:
You can only anchor to the sides, not to the center.

But to do what you want, you should use the onResize event. In the onResize method you can get the width and height of your form and then set the elements to the correct position.

That’s what I was looking for - thanks Joas.

Revisiting my question!

I have a set of elements grouped together (using Group from the right click menu on element formatting) that I need to move on a form resize event. Looks like when the elements are grouped in this way we cant use setLocatio() or even getLocation(). So is moving them in code not possible or did I miss a point ??

Nope, longstanding feature request of mine also! :)

The only way, that works, (dirty workaround) is setting everything inside tab’s!

Harjo:
Nope, longstanding feature request of mine also! :)

The only way, that works, (dirty workaround) is setting everything inside tab’s!

That’s a bit of a bugger then Harjo - cant anchor centrally and cant set location for groups of elements??? So no way to ensure a group of elements get’s correctly placed on form resize!

+1 for Harjo’s Feature Request - surely that one will be in v6 as its a developers release - and that’s an essential developers tool!

Hi Ian/Harjo,

Just a thought.
When you group elements that also have all different anchoring properties and you add anchoring to the group what should happen ?
Should the group anchoring overrule all? Or only overrule the elements that don’t have anchoring set ? Or perhaps add to the individual anchor settings ?

ROCLASI:
Hi Ian/Harjo,

Just a thought.
When you group elements that also have all different anchoring properties and you add anchoring to the group what should happen ?
Should the group anchoring overrule all? Or only overrule the elements that don’t have anchoring set ? Or perhaps add to the individual anchor settings ?

Well if you group a set of elements and you then look at the location of that group you see the x and y. I guess that’s the top left corner.

So, I’d expect Robert, that if you were able to set the location for the group that’s what would be changed and the group elements would retain the same relationship.

Not so sure if the anchors were set such that the group could grow or shrink though. I suspect that would have to be based on the Group container. Anchoring that only rather than resizing it.

What would be your view Robert?

Hi Ian,

Ah you’re right. I got ‘anchoring’ and ‘group’ in my mind and forgot about that you actually only wanted to set the location. Setting a location shouldn’t be any issue.

ROCLASI:
Hi Ian,

Ah you’re right. I got ‘anchoring’ and ‘group’ in my mind and forgot about that you actually only wanted to set the location. Setting a location shouldn’t be any issue.

That’s right it shouldn’t be but seems like there is no facility to do so with a grouped set of elements.

BTW was perusing your ServoyForge Servoy World video again last night - you’ve built a great support system there Robert!

And thanks for the feedback.

Kahuna:
That’s right it shouldn’t be but seems like there is no facility to do so with a grouped set of elements.

Yeah, +1 on that feature request.

Kahuna:
BTW was perusing your ServoyForge Servoy World video again last night - you’ve built a great support system there Robert!

Thanks! We (plural. There are more people working on this) do our best to make it even better. :)

In Servoy 6 (beta3) you can set size and location of a group in scripting.
The elements will be moved/resized accordingly.

You can also get/set other general properties via the group, for example bgcolor, font, etc.

Rob

rgansevles:
In Servoy 6 (beta3) you can set size and location of a group in scripting.
The elements will be moved/resized accordingly.

You can also get/set other general properties via the group, for example bgcolor, font, etc.

Rob

Excellent Rob - BTW v6 has a lot to live upto :lol:

Whilst on the topic - one of the things I find I want to do quite often is to take a row of elements and space them evenly. This is easy in layout mode with the tool bar - but during resize I’d like these elements to retain their relationship. So for example:

I have a row of menu buttons horizontally arranged. On resize I’d like to either,

  1. keep the buttons the same size and distribute them evenly from the current left position of the left button (anchored TOP,LEFT I guess), to the current right position of the right button (anchored TOP,RIGHT), or

  2. resize the buttons so they take up the same relative positions as the original but don’t overwrite each other.

Perhaps a centre anchoring point would be useful in regard to 1??

I have no clue what’s possible for you guys when it comes to altering this kind of stuff but I suspect this will be useful in other areas too both in vertical and horizontal arrangements.

Sense or rubbish??? :shock:

More extensive/advanced anchoring options is something being investigated for future versions.

Paul