Reference an actual location on the screen

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Reference an actual location on the screen

Post by adventuresofgreg » Wed Jun 02, 2021 7:14 pm

How do I reference the actual location of a mobile screen after I have scaled my stack to fit?

I'm trying to place a group on the BOTTOM of the screen, but no method works consistently with different devices.

I'm setting the fullscreen to "noBorder" then set the fullScreen to true. This scales the WIDTH and HEIGHT of my stack to match the WIDTH of the device which works very well, and preserves aspect ratio. However, since the HEIGHT is different depending on the devices aspect ratio, all I need to do is move the bottom button bar group to the bottom of the screen. But I've tried everything, and can't find a way of consistently referencing that location. It would make sense that it is the last item of the screenrect, but it is NOT. You have to scale the screen rect coordinate with how much your full screen was scaled, and that only works in some cases, but not for all devices.

Thanks!
Greg

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Reference an actual location on the screen

Post by richmond62 » Wed Jun 02, 2021 7:35 pm

all I need to do is move the bottom button bar group to the bottom of the screen.
Well, you could do this sort of thing:

Code: Select all

put the screenrect into SCRNT
put item 4 of SCRNT into BUM
set the bottom of group "MyButtons" to BUM
It would make sense that it is the last item of the screenrect, but it is NOT.
That is because you are scaling your stack proportionally, rather than just simply to the dimensions of the screen.

So, it is probably time to play some 'daft' Mathematical games, or . . . wait a "fffff...ing" moment . . .

just send your group of buttons to the bottom of the actual stack rather than the screen.

Code: Select all

on resizeStack NW, NH, OW, OH
   put ((NW/2) - 168) into NPOZ
   set the bottom of group "MyButtonz" to NH
   set the left of group "MyButtonz" to NPOZ
end resizeStack 
-
SShot 2021-06-02 at 21.47.38.jpg
-
Here is the stack to play around with:
Attachments
DEMO.livecode.zip
Here's the stack.
(168.74 KiB) Downloaded 193 times
Last edited by richmond62 on Wed Jun 02, 2021 7:50 pm, edited 1 time in total.

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: Reference an actual location on the screen

Post by adventuresofgreg » Wed Jun 02, 2021 7:42 pm

ya that doesn't work. It seems that when you scale your stack, all of the coordinates are somehow scaled as well, and it gets confusing due to the iPhoneDeviceScale.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Reference an actual location on the screen

Post by richmond62 » Wed Jun 02, 2021 7:51 pm

I have extended my posting: go back and look, and THEN abuse me. :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Reference an actual location on the screen

Post by richmond62 » Wed Jun 02, 2021 8:01 pm

it gets confusing due to the iPhoneDeviceScale
Stop worrying about the iPhone and start worrying about the dimensions of the stack.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Reference an actual location on the screen

Post by FourthWorld » Wed Jun 02, 2021 8:18 pm

Scaling complicates many things, which is among the reasons almost none of the apps on your phone do it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: Reference an actual location on the screen

Post by adventuresofgreg » Wed Jun 02, 2021 10:06 pm

richmond62 wrote:
Wed Jun 02, 2021 8:01 pm
it gets confusing due to the iPhoneDeviceScale
Stop worrying about the iPhone and start worrying about the dimensions of the stack.
I think that dimensions of the stack change when we use the auto scaling:

set the fullscreenmode of this stack to "Letterbox"
set the fullscreenmode of me to true

Once you do that, you don't know what the dimensions are anymore. You can get the screen rect, but as I said, the coordinates seem to refer to the scaled stack size... somehow. The closest I got to referencing the bottom of the stack was to take the original stack width and calculate the scale factor, then multiply the screen height by that scale factor. This worked for devices that rendered at 2x, but then failed for the 3x devices. And failed again for other devices for no apparent reason.

As Richard said, perhaps the best way is to not use scaling, and move groups around to fill up the screen according to the screen rect.

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

Re: Reference an actual location on the screen

Post by bwmilby » Thu Jun 03, 2021 1:32 am

Simple. Don’t try to use screenRect on mobile. Use the rect of this card instead.
Brian Milby

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

Post Reply

Return to “iOS Deployment”