Controlling grouped objects

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Controlling grouped objects

Post by jalz » Wed Apr 23, 2014 2:16 pm

Hi Guys,

On a roll now, things seem to be finally falling into place. I do have another query, its more to do with efficiencies of grouped objects.

I have a two fields laid out next to each other aligned top with both the heights set to 21 (indicating a single line). The fields are called description and price. I have placed a solid rectangle around both fields. I have then grouped all three objects together and called it myPriceRow.

The question is the description field may contain x number of lines and I want the field to autoresize to display all the content of the field. So checking out the dictionary I came across the formattedheight command. I figured out that I can obtain the formattedheight of the content within the description field and then set the height of the description field so that its slightly greater than the formatted height of the content. This seemed to work fine, however two things I noted as issues.

1) When I set the height of the description field, the field increases in size from the centre outward, making description and price aligned in the centre rather than the top. Is there a way I can lock the top location before I set the height of description, so it grows downward? If not I will just have to get the top location of description before its grown and then readjust the alignment of the fields afterwards.
2) The second thing was, the solid rectangle which was around the fields needs to grow as well depending on the description field size. I can manually set the height of the rectangle object so it’s the formattedheight +10. However because I’ve grouped the items together, can I somehow use the groups properties to extend the description field and the solid rectangle in one line of code?

Both of the these things above I can do manually, I was mainly querying if grouping the objects I can write less lines to expand both the description field and the rectangle surrounding it.

Finally, not related, but curious. What are template controls? Do we only have datagrid row template controls or would my grouped object myPriceRow which I use again and again in a script be considered a templated control? I know datagrids contain template controls, do most of you use template controls for repetitive things or have I misinterpreted the word ‘templated’.

Thanks once again

Jalz

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Controlling grouped objects

Post by keram » Wed Apr 23, 2014 6:47 pm

Hi Jalz,
jalz wrote:Is there a way I can lock the top location before I set the height of description, so it grows downward?
Try with this, maybe it will work:

set the top of fld "description " to 14
set the top of fld "price" to 14
set the top of grp "myPriceRow" to 14

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Controlling grouped objects

Post by keram » Wed Apr 23, 2014 6:59 pm

The numbers I gave above you may adjust of course according to your layout.
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Controlling grouped objects

Post by magice » Wed Apr 23, 2014 7:11 pm

Is there a way I can lock the top location before I set the height of description, so it grows downward?
You can try

Code: Select all

put the topLeft of fld "myField" into tTop
lock screen
set the height of fld "myField to 100
set the topLeft of fld "myField" to tTop
unlock screen


jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: Controlling grouped objects

Post by jalz » Wed Apr 23, 2014 9:47 pm

Thanks Guys,

yes I've sorted this out by setting each object manually using the set the height command. I was just wondering whether there was a more efficient way of working with grouped objects when asking the question.

All the best
Jalz

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Controlling grouped objects

Post by dunbarx » Wed Apr 23, 2014 10:37 pm

I have never really used the geometry pane of any object, mainly because I do not know how it works. Does anyone know if it is possible to do what Jalz wants by using this tool? It seems that scaling an enclosing rectangle graphic when the field height changes is just what this gadget would be good for. (I do not see a natural way to hold the top of the field when the height changes. LC seems to base these changes on an immovable loc, not any edge.)

I think a tutorial on the geometry manager would be in order. I mean like a real lesson from Runrev.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Controlling grouped objects

Post by dunbarx » Wed Apr 23, 2014 10:42 pm

Jalz.

It occurs to me that you could do this another way. Instead of simply setting the height of the field to the formattedHeight (which is always symmetrical about the loc), you could get that property and set the rect instead. Do you see what i mean? The rect could hold the top of the field invariant, and simply slide the bottom. Should be much shorter to implement.

Craig

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Controlling grouped objects

Post by magice » Wed Apr 23, 2014 10:48 pm

I have played with the geometry manager, and decided that it is either broken or just doesn't do what I think it's supposed to do. Either way, It is an area of LC that greatly needs revamping.

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Controlling grouped objects

Post by dave.kilroy » Thu Apr 24, 2014 12:02 am

Jalz - I also would be thinking of controlling the rect as Craig describes - and yes I agree Magice, the geometry manager should be given a wide berth...
"...this is not the code you are looking for..."

Post Reply