Using the IDE I can put a control locked Left/Top, Center/Top, Right/Top, Left/Middle, Center/Middle, Right/Middle, Left/Bottom, Center/Bottom and Right/Bottom like this:
If the page grows the controls move to keep the distance to the WebPage border or the Center and Middle of the page just by changing the locks:
Left/Top
Center/Middle
Right/Bottom
You get the idea.
Now I’m trying to use EmbedWithin and replicate this behavior without success. The only one I can do is the Left/Top.
I reviewed Feedback cases like:
61543 - Web 2.0: EmbedWithin is being positioned by percentage instead of pixels
61210 - WebContainer.EmbedWithin does not honor the Left and Top parameters
The code in the browser for Center/Top button is:
<div id="WU8MdJ" class="XojoButton" style="left: 50%; top: 20px; width: 150px; height: 38px; margin-left: -75px; position: absolute;">
but the container using EmbedWithin is:
<div id="y9jPhu" class="XojoContainer" style="left: 15.83%; top: 20px; width: 150px; height: 38px; margin-left: -75px; outline: none; position: absolute; overflow: initial;">
so the only difference is the left %
I don’t understand why or how that value is calculated (15.83%) and not use 50% as used with the IDE, the code to embed is:
var mycc as new ContainerControl1
mycc.LockTop = True
'mycc.LockLeft = False
mycc.LockHorizontal = True
mycc.EmbedWithin(Self, 20, 20, 150, 38)
I tried without LockLeft, with LockLeft = False and with LockHorizontal but nothing works as I expected.
Do you think it will be possible to change how EmbedWithin works to replicate what we can do with the IDE?
The other thing is the right and bottom locked controls, for example Right/Bottom button, the code in the browser is:
<div id="UiWHHZ" class="XojoButton" style="right: 20px; bottom: 29px; width: 150px; height: 38px; position: absolute;">
and the code for EmbedWithin
<div id="Un2cou" class="XojoContainer" style="right: 430px; bottom: 342px; width: 150px; height: 38px; outline: none; position: absolute; overflow: initial;">
the problem I see is that EmbedWithin uses:
WebContainer.EmbedWithin(View as WebView, left as Integer, top as Integer, width as Integer, height as Integer)
so there is no way to indicate a right and bottom value.
I was thinking of using something like this to compensate and instruct Xojo that the values are not left/top but right/bottom:
var mycc as new ContainerControl1
mycc.LockRight = True
mycc.LockBottom = True
mycc.EmbedWithin(Self, -20, -29, 150, 38)
but that may cause conflicts with people that want to actually use -20 as Left. So I’m think if it is possible to add something like
WebContainer.EmbedWithin(View as WebView, left as Integer, top as Integer, width as Integer, height as Integer, right as boolean = False)
to have an optional value to indicate that instead of using Left/Top use Right/Bottom for the first 2 values.
Does this make sense?