Log in

View Full Version : Anchoring issue/bug



darrenan
March 22nd, 2023, 18:22
I have two controls set up like this:



<genericcontrol name="columnanchor">
<!-- <anchored height="0">
<top offset="40" />
<left offset="30" />
<right offset="-30" />
</anchored> -->
<anchored position="insidetop" offset="-30,40" />
<disabled />
<invisible />
</genericcontrol>

<stringcontrol name="instructions_label">
<font>sheetlabel</font>
<nodrag />
<readonly />
<anchored height="40">
<top parent="columnanchor" anchor="bottom" relation="relative" offset="7" />
<left parent="columnanchor" anchor="left" />
<right anchor="right" />
</anchored>
<multilinespacing>20</multilinespacing>
<static textres="pc_label_parse_instructions" />
</stringcontrol>


If I change the <right> anchor of "instructions_label" to <right parent="columnanchor" anchor="right" /> then the control disappears. I've tried this with both of the anchoring schemes in columnanchor and see the same behavior. I simply want the stringcontrol to be anchored to the left and right extents of the columnanchor control. What am I missing/doing wrong?

Obviously I could just directly set the offset= on the <right> element to a static value, which seems to work fine. I'm just wondering why the approach above isn't working. I feel like I'm missing something obvious.

damned
March 23rd, 2023, 10:36
Would position="below" inherit left and right?

Moon Wizard
March 25th, 2023, 17:42
It's because your columnanchor does not have a width. In the other examples in the built-in rulesets, the column anchor is usually tied to an offset from the left/right edges of the parent window, which gives it an implied dynamic width based on the size of the window.

In your example above, your columnanchor has a top/left anchor, but no right/bottom anchors, nor width/height specifiers. This means that it will default to zero height/width.

Regards,
JPG

darrenan
March 27th, 2023, 15:54
I thought "insidetop" had implied left and right anchors? That's what the anchors diagram seems to suggest. And yes, I should have put height 0 on that version of the anchor.

Also, the commented-out version did have all those anchors and I was seeing the same issue.

darrenan
March 27th, 2023, 16:07
"below" would put it off the bottom of the window since it's not attached to a control, but the containing window. I believe insidetop is the appropriate anchor based on the diagram.

darrenan
March 27th, 2023, 16:09
Ok, the actual problem was that I had <invisible/> on columnanchor. I guess you can't anchor to invisible controls. Once I removed that it started working just fine.

superteddy57
March 27th, 2023, 16:11
Invisible eliminates it as an anchoring target.

Moon Wizard
March 27th, 2023, 16:53
You are correct on the "insidetop", so sorry for the red herring. Controls must be visible to be anchored to, as you've found.

Regards,
JPG