Do Native Fields Scale

This is the place to discuss anything relating to MobGUI

Moderators: heatherlaine, kevinmiller, robinmiller, malte, splash21

Post Reply
srbarlow3
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 28, 2012 5:20 pm

Do Native Fields Scale

Post by srbarlow3 » Thu Feb 20, 2014 5:02 pm

I finally worked my way through the Apple iOS maze and have been able to install my app onto my devices for testing. Wow...it really works....was my first thought. Looks good and works just like the simulator. I did it!

A Question: How do native input fields scale under "exact fit"?

I use one native input field and two regular Livecode fields on a simple input screen. I chose the native field since I needed a keyboard ( set to "decimal" ) to enter numbers only and the other inputs are both dates so a locked field with a mouseDown script invoking the mobilePickDate command works nicely. It looks great on the small screens (although I could never get the borders of the LC and native fields to perfectly match ). The problem is on the iPad. I am using "exact fit" so the lc fields (and everything for that matter) look beautiful on the larger resolution. The fonts are scaled up to fit the scaled field sizes perfectly. Unfortunately the font size in the native field seems to stay smaller so the three fields don't look right side by side. I noticed this throughout the app on any native fields used. The sizes if the fields scale, but the fonts used don't

I was considering using LC fields throughout my app... or at least on the screen I have been describing. I am new and I thought there was some advantage with native fields, namely that they eliminated the need to invoke the keyboard? I have experimented and it seems that in the simulator, LC fields, when focused invoke an iOS keyboard too? So I tried placing a LC field on a card with the following script to get the correct keyboard:

on mouseEnter
mobileSetKeyboardType "decimal"
end mouseEnter

on mouseLeave
mobileSetKeyboardType "default"
end mouseLeave

this seems to work and I suppose I can add

on closeField
-- error check data
end closeField

It worked fine except my problem is this... when the card initially opens the field ( the only unlocked LC field on the card) also opens the keyboard (the default one). I don't want any keyboard open until the user intends to use it by inserting the cursor and clicking on the LC field.

Any ideas how to do this...how to avoid having the keyboard pop open when the card opens.

My end goal is to have all the fields on the input screen appear the same font size regardless of the device. I actually like the scaling LC look better where all fields properties are identical if I can resolve the keyboard issue.

Thanks for any ideas

Russ

ps. mobilePickDate invokes a unbounded wheel somewhere far up the iPad screen unlike the very nice dialog at the bottom of the screen on smaller iPhone/iPod devices. It almost looks like a bubble from a comic book as it has a little pointed tab at the bottom. It would be really nice if they were close to the fields that invoked them especially with the little tail pointing to the field being set by the wheel.. Is there any easy way to affect their location?

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Do Native Fields Scale

Post by Dixie » Thu Feb 20, 2014 7:24 pm

hi..

try this...

Code: Select all

on openCard
   focus on nothing
end openCard
set the traversalOn ...'focusable' in the field property inspector... to false
and in the script of your field(s)

Code: Select all

on mousedown
   set the traversalOn of me to true
   focus on me
end mousedown
Run in the simulator, the keyboard will popup when you click on a field and go away when you click outside a field...

srbarlow3
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 28, 2012 5:20 pm

Re: Do Native Fields Scale

Post by srbarlow3 » Fri Feb 21, 2014 3:40 am

It worked wonderfully as promised...Thanks. I had no idea what "traversalOn" was but I looked it up.

Russ

srbarlow3
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 28, 2012 5:20 pm

Re: Do Native Fields Scale

Post by srbarlow3 » Sat Feb 22, 2014 4:14 am

One other issue perhaps someone can help with. I have noticed when livecode's new scaling is used the result is that the native input fields scale on the card proportionally but, unlike the text in a livecode field, the text in the native fields seem to stay at the original font size. This means when I put my app built for an iPhone on an iPad, it has ridiculously small letters in a large field.

I replaced fields on another card with lc fields but the card I am concerned about has a native input scroll field. I am not sure that is as easily replaced by a live code field.

My options:

1). Could I somehow set the font size in the native fields to scale with some screen dimension. That might make the letter size proportionate with the expanded field size?

2). Is there some way to script a lc field to imitate the behavior (at least mostly) of a native scrolling input field.

I am fairly new to this so mobGUI has been a godsend... But it has also sheltered me from some of what I need to know now.

Thanks in advance for any help.

Russ

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Do Native Fields Scale

Post by Jellicle » Sat Feb 22, 2014 9:23 am

Just detect the device and set the text size of the native text control appropriately.

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

srbarlow3
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 28, 2012 5:20 pm

Re: Do Native Fields Scale

Post by srbarlow3 » Sat Feb 22, 2014 9:17 pm

Thanks Gerry.

I ended up doing this:

Code: Select all

   put item 1 of  iphoneDeviceResolution() into actWidth  -- put the actual screen width on the device
   put actWidth div 640 into scaleFact  -- get a ratio between the deployment and the development pixel width
   put 15 * scalefact into newFontSize  -- up scale the fontSize proportionately 
   mobileControlSet "myField", "fontSize", newFontSize  -- set the fontSize of the native field
Is there a better way to get the device dimensions? This will only work on iOS and I'd like to deploy on Android too.

My results are great. The fonts ares upscaled so that with the
fullscreenmode set to to "exactFit" the text is sized right for the upscaled field sizes

Thanks again for your help

Russ

Post Reply

Return to “MobGUI”