Reference an actual location on the screen
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Reference an actual location on the screen
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
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
-
- Livecode Opensource Backer
- Posts: 9375
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Reference an actual location on the screen
Well, you could do this sort of thing:all I need to do is move the bottom button bar group to the bottom of the screen.
Code: Select all
put the screenrect into SCRNT
put item 4 of SCRNT into BUM
set the bottom of group "MyButtons" to BUM
That is because you are scaling your stack proportionally, rather than just simply to the dimensions of the screen.It would make sense that it is the last item of the screenrect, but it is NOT.
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
Here is the stack to play around with:
- Attachments
-
- DEMO.livecode.zip
- Here's the stack.
- (168.74 KiB) Downloaded 195 times
Last edited by richmond62 on Wed Jun 02, 2021 7:50 pm, edited 1 time in total.
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: Reference an actual location on the screen
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.
-
- Livecode Opensource Backer
- Posts: 9375
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Reference an actual location on the screen
I have extended my posting: go back and look, and THEN abuse me.
-
- Livecode Opensource Backer
- Posts: 9375
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Reference an actual location on the screen
Stop worrying about the iPhone and start worrying about the dimensions of the stack.it gets confusing due to the iPhoneDeviceScale
-
- VIP Livecode Opensource Backer
- Posts: 9833
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Reference an actual location on the screen
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: Reference an actual location on the screen
I think that dimensions of the stack change when we use the auto scaling:richmond62 wrote: ↑Wed Jun 02, 2021 8:01 pmStop worrying about the iPhone and start worrying about the dimensions of the stack.it gets confusing due to the iPhoneDeviceScale
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.
Re: Reference an actual location on the screen
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
Script Tracker https://github.com/bwmilby/scriptTracker