Mobile device "size" during development

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rjenkinsgb
Posts: 12
Joined: Tue Feb 17, 2015 1:30 pm

Mobile device "size" during development

Post by rjenkinsgb » Mon Apr 06, 2015 11:22 am

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.

JacobS
Posts: 58
Joined: Mon Aug 20, 2012 8:41 pm

Re: Mobile device "size" during development

Post by JacobS » Mon Apr 06, 2015 2:34 pm

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

rjenkinsgb
Posts: 12
Joined: Tue Feb 17, 2015 1:30 pm

Re: Mobile device "size" during development

Post by rjenkinsgb » Tue Apr 07, 2015 12:18 pm

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.

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Mobile device "size" during development

Post by dave.kilroy » Tue Apr 07, 2015 3:42 pm

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
"...this is not the code you are looking for..."

JacobS
Posts: 58
Joined: Mon Aug 20, 2012 8:41 pm

Re: Mobile device "size" during development

Post by JacobS » Tue Apr 07, 2015 7:16 pm

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

Post Reply