Page 1 of 1
Mobile device "size" during development
Posted: Mon Apr 06, 2015 11:22 am
by rjenkinsgb
Hi,
I'm trying to develop a mobile app that will adjust to the device screen resolution.
When starting in debug, the screenRect value seems to return the computer monitor size rather than any reasonable mobile device size, even though I only have iphone/ipod set in the standalone settings.
Is it possible to set the debug "screen size" & orientation in livecode so sensible values are seen (from screenRect etc) while debugging?
Thanks,
RJ.
Re: Mobile device "size" during development
Posted: Mon Apr 06, 2015 2:34 pm
by JacobS
Hi R.J.
When I develop mobile apps for Android, I always use the width and height of the current card to determine how to adjust the layout of that card. So in the resizeStack function I use:
Code: Select all
on resizeStack
if the width of this card < the height of this card then
resizePortrait
else
resizeLandscape
end if
end resizeStack
and then define two functions elsewhere that change the layout of the screen:
Code: Select all
on resizePortrait
put the width of this card into tW
put the height of this card into tH
set the width of field "Instructions" to (1*tW)
set the height of field "Instructions" to (.121*tH)
...
end resizePortrait
on resizeLandscape
put the width of this card into tW
put the height of this card into tH
set the width of field "Instructions" to (.5*tW)
set the left of field "Instructions" to (.05*tW)
...
end resizeLandscape
I also use the resizeStack logic in the preOpenCard handler so that the resize works on mobile devices when not in debug mode.
In debug mode, all you need to do is resize the stack through the property inspector or with the mouse. It's pretty easy to see what the app will look like on all sorts of device resolutions and in the different orientations.
Hope that helps,
Jacob
Re: Mobile device "size" during development
Posted: Tue Apr 07, 2015 12:18 pm
by rjenkinsgb
Hi,
thanks, I'd not thought of checking the size of the card.
It looks like there is a bug in the screenrect function.
RJ.
Re: Mobile device "size" during development
Posted: Tue Apr 07, 2015 3:42 pm
by dave.kilroy
Hi RJ - remember the screenRect returns the size of the screen(s) the computer is running and not your app - so invoking it on your computer will indeed return the size of your monitor (have you tried calling it when your app is on a mobile device?
Kind regards
Dave
Re: Mobile device "size" during development
Posted: Tue Apr 07, 2015 7:16 pm
by JacobS
Dave is absolutely right! The screenRect function is working exactly as it should: it returns the size of the screen, not the card!
I would definitely recommend using the dimensions of the card (or the stack) for mobile development. It makes developing in the LiveCode IDE much easier.
Jacob