Dynamic Objects Not Positioning Correctly

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
xclntdesign
Posts: 34
Joined: Sun Feb 06, 2011 8:33 pm

Dynamic Objects Not Positioning Correctly

Post by xclntdesign » Mon Aug 20, 2012 10:24 pm

I am creating 2 objects dynamically based on data: a field and a button. I am creating them inside an existing group.

For reasons unknown, the new objects are ignoring the commands I am using to set the top and left of the object for positioning. I know the syntax is correct.

Code: Select all

set the top of field newField of stack myStack to 479
set the left of field newField of stack myStack to 128
When I enter the correct left and top positions in the Property Inspector and save the stack, the objects jump right back to the original, incorrect position.

I have checked the objects and there is no geometry being set.

Any ideas?

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Dynamic Objects Not Positioning Correctly

Post by shaosean » Mon Aug 20, 2012 10:31 pm

You mentioned that the controls are being created in the group.. Do you have the lockLocation property of the group set to true?

xclntdesign
Posts: 34
Joined: Sun Feb 06, 2011 8:33 pm

Re: Dynamic Objects Not Positioning Correctly

Post by xclntdesign » Tue Aug 21, 2012 1:13 am

I've tried it both ways, on and off, set before and after the positioning controls. Didn't seem to make a difference.

The default I'm using is set lockloc to false.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Dynamic Objects Not Positioning Correctly

Post by shaosean » Tue Aug 21, 2012 3:07 am

Another quick question.. Is "newField" the actual name of the field or a name of a variable you are using? If it is either of those, it is a reserved word..

newField message
newButton message

xclntdesign
Posts: 34
Joined: Sun Feb 06, 2011 8:33 pm

Re: Dynamic Objects Not Positioning Correctly

Post by xclntdesign » Tue Aug 21, 2012 1:34 pm

That's just an example I was using. The actual variable names were newFieldName and newGraphicName.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Dynamic Objects Not Positioning Correctly

Post by shaosean » Tue Aug 21, 2012 2:13 pm

Any chance to peek at the actual stack? The sample code you posted should work, but you stated that even doing it through the Inspector caused the controls to revert to their previous locations..

xclntdesign
Posts: 34
Joined: Sun Feb 06, 2011 8:33 pm

Re: Dynamic Objects Not Positioning Correctly

Post by xclntdesign » Tue Aug 21, 2012 2:38 pm

Here's the section that's giving me grief. The names of some variables have been changed to protect the innocent.

In a nutshell: The script steps through an array of appointments, and creates a text field in a specific location with the appointment info, and a transparent button on top of that field so that the appointment can be acted upon (get details, edit, delete, etc).

The button appears in the right place for some reason, the text field does not.
Attachments
dynPos.livecode.zip
(1.7 KiB) Downloaded 341 times

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Dynamic Objects Not Positioning Correctly

Post by shaosean » Tue Aug 21, 2012 7:23 pm

*sigh* Sorry, I forgot to mention about saving it in the legacy stack format.. I never upgraded to LiveCode due to moving to other languages..

xclntdesign
Posts: 34
Joined: Sun Feb 06, 2011 8:33 pm

Re: Dynamic Objects Not Positioning Correctly

Post by xclntdesign » Tue Aug 21, 2012 8:13 pm

Saved this one as 2.7.
Attachments
dynPos27.livecode.zip
(1.71 KiB) Downloaded 363 times

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Dynamic Objects Not Positioning Correctly

Post by shaosean » Tue Aug 21, 2012 10:15 pm

coding errors on this line

Code: Select all

put ceiling(currentAppointment[3]]) / .5) into calendarDuration
should(?) be

Code: Select all

put ceiling(currentAppointment[3] / .5) into calendarDuration

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Dynamic Objects Not Positioning Correctly

Post by shaosean » Tue Aug 21, 2012 10:21 pm

Sorry, but there are too many un-intialized variables and apparently a missing stack.. If you would like we can remote screen share and I can help you out on your computer (I am sure someone I have done this with in the past will vouch for me ;)

Post Reply