Position control

Getting into LiveCode for iOS? Ask your questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Re: Position control

Postby jacque » Fri May 05, 2017 10:43 pm

Did you remove iphoneUseDeviceResolution? When using fullscreenmode, let the engine scale rather than trying to figure out the pixel locations yourself. It does a good job.

I'm not sure why you're getting those odd results. When positioning objects, assume the normal card rect and the engine will calculate the relative position based on the scaling it's doing. In your example you want the button inset by 14 (relative) pixels from the top and bottom. Your stack is about twice as large as the screen, so the engine will scale the positions by about half, but you don't need to worry about that. Just set the position as though the card is normal size.

Picky thing: stack and card rects always begin with 0,0 so you don't need to get those or add the offsets to them. This should work with one line of script:

Code: Select all
set the topleft of btn "testButton" to 14,14


Does it work without iphoneUseDeviceResolution?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 3798
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN

Re: Position control

Postby chelling » Sat May 06, 2017 1:51 pm

I did remove iphoneUseDeviceResolution hoping that would be the fix. The top of the button is being placed. The left position is apparently adding the width of the test button + the 14 pixels (Top 14, Left 106). Setting the loc to 14, 14 results in Left -32, Top 60. Setting the TopLeft of the button results in Top 14, Left 106. This is the test stack I have been working with https://drive.google.com/open?id=0B3g04 ... C1idHRwQzg
chelling
 
Posts: 67
Joined: Tue Mar 06, 2007 3:14 am

Re: Position control

Postby jacque » Sat May 06, 2017 7:36 pm

I don't see any scripts in that stack. BTW, any stack name that begins with "rev" can't easily be viewed or recognized in the IDE. That string is reserved for IDE stacks. I had to change the name to see what was there.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 3798
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN

Re: Position control

Postby chelling » Sat May 06, 2017 11:00 pm

The stack name is Screen_Test.livecode.

This is the stack script:

-- on preOpenStack
-- if the environment is "mobile" then
-- iphoneUseDeviceResolution true
-- set the fullscreenmode of me to "showAll"
-- set the rect of this stack to screenRect()
-- end if
-- end preOpenStack

on preOpenStack
set the fullscreenmode of this stack to "showAll"
end preOpenStack


There are 8 buttons to test screen/card properties, placing the button, ect.

I just downloaded it on a different computer and it is intact.

Now I am totally confused.
chelling
 
Posts: 67
Joined: Tue Mar 06, 2007 3:14 am

Re: Position control

Postby jacque » Sun May 07, 2017 5:40 pm

I'm confused too, that isn't the stack I saw. I'll download again later today and see what I get.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 3798
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN

Re: Position control

Postby chelling » Sun May 07, 2017 6:45 pm

Thanks. I really do appreciate your help. I have worked though this using LiveCode Business 8.1.3, 8.1.4 (RC1), and 9 (dp6). I have changed the orientations from landscape, to portrait to both. This should be easy.
chelling
 
Posts: 67
Joined: Tue Mar 06, 2007 3:14 am

Re: Position control

Postby jacque » Sun May 07, 2017 9:22 pm

I'm not sure what happened the first time, but I was able to run your stack today. It's behaving as I'd expect.

The measurement in the "button loc" field isn't really reporting the location, it is reporting the left and right edges of the test button, so what you say is the "top" is actually the left. The right edge is at 106 after repositioning. The actual location of the button (its center, which the stack doesn't measure anywhere) after moving it is 60,55. The topleft of the button after moving is 14,14. All these measurements match in either environment.

When using fullscreeMode "showAll", any areas outside the card rect are visible. Because of the off-card visual areas, what appears to be very far from the top of the screen in portrait mode is still actually 14 pixels in from the top edge of the card rectangle. It is possible to set the position to a negative number which will put the button outside the card area, but there are some disadvantages to this: LC will not always redraw areas outside the card, so if you navigate to another card, remnants of the previous card will remain onscreen, even if the button doesn't really exist on the new card. There are ways to script around this, but it's usually better to rethink the stack design so that natural scaling looks okay in any orientation on any device. I frequently just set the backcolor of the stack to a compatible, and sometimes contrasting, color so that a natural border appears around the actual card rectangle. If you do that in your test stack, you'll see how the measurements are accurate relative to the card.

Edit: You can also see what's going on more clearly if you set the fullscreenMode to "letterbox".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 3798
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN

Re: Position control

Postby chelling » Sat May 13, 2017 5:48 pm

Thanks for the explanation.
chelling
 
Posts: 67
Joined: Tue Mar 06, 2007 3:14 am

Previous

Return to iOS Deployment

Who is online

Users browsing this forum: No registered users and 3 guests