Anchoring controls in a datagrid form row template

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
stam
Posts: 250
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Anchoring controls in a datagrid form row template

Post by stam » Tue Jul 21, 2020 9:11 pm

Hi all,
i'm encountering weird issues (or at least i'm not doing it right!) when trying to anchor items with the geometry manager for a row prototype.

In particular, I'm trying to set 3 labels in a row template for a datagrid form to stick to the right edge when resizing.
I imagined that going to row template -> edit group -> select label -> geometry manager -> click the line that binds the control to the right edge would do it.

I stop editing, refresh datagrid and when i resize... it seems to automatically bind the control to the left edge... no matter what it do, so that the labels appears to jump from right of the datagrid row to the left on resizing.

Clearly i'm not doing this right. Can the geometry manager be used for this? if not what would be the usual way to code this?

stam
Posts: 250
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Anchoring controls in a datagrid form row template

Post by stam » Tue Jul 21, 2020 9:45 pm

more specifically in my example, the image below shows what happens when i attempt to anchor the top right label field to the the right edge... even just nudging the stack width 1 pixel causes the label to jump from right to left (it's quite a wide label, the left edge of it isn't visible but becomes anchored to the left border, instead of the right as i thought would be the case) and setting the stack width back to original size does not resolve the issue (click 'refresh data grid' does put it back to it's proper location)
Image

the setting i change for this label is shown below (and btw the only difference in setting this to position rather than scale is that with scale the text not only jumps left but also is not rendered when the stack width gets below a threshold, whereas with 'position' it will just push the label left)
Image

I appreciate i must be 'doing it wrong' but can't seem to find the correct answer... many thanks for pointing me in the right direction!

bwmilby
Posts: 362
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Anchoring controls in a datagrid form row template

Post by bwmilby » Tue Jul 21, 2020 11:31 pm

I will need to test this later but am pretty sure this is not going to work out well. GM caches information based on the card where the object resides. Due to how the DG works, it probably won’t be updated correctly.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

stam
Posts: 250
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Anchoring controls in a datagrid form row template

Post by stam » Wed Jul 22, 2020 3:30 am

bwmilby wrote:
Tue Jul 21, 2020 11:31 pm
I will need to test this later but am pretty sure this is not going to work out well. GM caches information based on the card where the object resides. Due to how the DG works, it probably won’t be updated correctly.
You're undoubtedly right... in my case i've set the DG to resize with with stack which works well enough, but the controls don't align as expected (jump to the left instead of sticking to the right). However if i resize the DG independently i get different/unpredictable behaviours.

I gave up on the geometry manager and tried to lay this out in code in the script for the row template layout section. I can set the coordinates correctly in the LayoutControl pControlRect, pWorkingRect handler. For some reason it took multiple saves for this to 'take' but now works as expected (I'm guessing there was some funky geometry manager setting still lingering somewhere and not being rid of easily.)

Simple enough code:

Code: Select all

On LayoutControl pControlRect, pWorkingRect
    local theLeft, theRight, theTop, theBottom
    put item 2 of the rect of field "right label" of me into theTop
    put item 4 of the rect of field "right label" of me into theBottom
    put item 3 of pWorkingRect - 5 into theRight
    put theRight - the width of field "right label" of me into theLeft
    set the rect of field "right label" of me to theLeft, theTop, theRight, theBottom 
    //the field "right label" remains in constant position relative to the right edge of the row
end LayoutControl
Again would appreciate if someone can point out if i've been using the geometry manager wrong or if there is a better way of doing this..

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”