V0.17 - Open heart surgery

This is the place to discuss anything relating to MobGUI

Moderators: heatherlaine, kevinmiller, robinmiller, malte, splash21

Post Reply
splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Location: UK
Contact:

V0.17 - Open heart surgery

Post by splash21 » Thu Jul 21, 2011 11:57 am

V0.17 fixes an issue which popped up recently. Thanks to Rob Glassman and Gary Simpson for both sending sample code to help track the bug.

MobGUI was put on the operating table and the creation of all native iOS controls now happens in the preOpenCard handler (the snippet that MobGUI automatically inserts).
This fixes the problem (detailed below), so no workaround is required any more - BUT - it was quite a big change behind the scenes, so rather than just posting the update and letting the plugin detect it, I thought it would be best to post it here first. I've been testing this version and everything looks fine, but I'll wait until I get some feedback before making it available in the normal way!

If you want to try it out, you can get it here;
MobGUI_V0-17.zip
(443.52 KiB) Downloaded 433 times
I've also added the uText property to the native field controls for getting and setting their text. You can now do the following;

Code: Select all

set the uText of group "MyUITextField" to "test123"
put the uText of group "MyUITextField" into tText
This code also works in the IDE, as the text field is represented by a LiveCode field control.


The problem
When moving to a new card that has native text controls and populating those controls with data in the preOpenCard handler, the data doesn't appear - only the first time!

The first time the card is visited, the native text fields don't exist as they haven't been created yet, so the data doesn't show.

When the controls are created (in the openControl message - which comes after the preOpenCard and openCard messages) they are set to their default values. If you enter default values for the controls in MobGUI, you'll see those values appearing.

Any subsequent visits to the card work fine, as the text fields now exist.


The workaround
To make it work, the following was added to the preOpenCard handler and the script to populate the fields was in the 'populate' handler

Code: Select all

send "populate" to me in 1 tick

Any feedback for V0.17 will be greatly appreciated! 8)
LiveCode Development & Training : http://splash21.com

John Allijn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 65
Joined: Sat Feb 26, 2011 10:02 am

Re: V0.17 - Open heart surgery

Post by John Allijn » Fri Jul 22, 2011 9:58 am

Hi John,

The plugin looks good. I installed it right away. Because of the manual install I had to register again, but that wasn't a problem.
I can't seem to access the data in the text field though. I created three text fields for firstname, lastname and email entries.
Just to be sure I backupped my stack and did the mobgui restore, which was successful.

On the card I created a button "Save", which takes the data from the fields and puts it into variables. After that it calls a command that writes the data to a text file in my special documents folder.
The save button's script is very straight forward and, as far as I can tell, is O.K.
However, the uText appears to be empty.

Here is the code of my save button:

Code: Select all

Global voornaam                  -- first name
global achternaam                -- last name
global email                     -- email adress

-- sample script to access text in uitextfield:
--set the uText of group "MyUITextField" to "test123"
--put the uText of group "MyUITextField" into tText

on mouseUp
   
   Answer "Begin getting data"
   
   put the uText of group "fVoornaam" into Voornaam 
   put the uText of group "fAchternaam" into Achternaam
   put the uText of group "fEmail" into Email
   
   
   answer voornaam && Achternaam && email  -- NOTE: In the simulator I get a blank dialog-box
   
   
   -- continue with the script for debugging purposes
   if voornaam is empty
   then
      put "Demo" into voornaam
      put "Demona" into achternaam
      put "a@b.c" into email
      answer voornaam && Achternaam && email
   end if
   
   send WriteSavedVariables
   answer "Variables saved to file."
   
end mouseUp
I use livecode 4.6.3, mobgui 0.17 and the iOS simulator 4.3 with 4.3.2 set as iOS operating system on an iPhone 3GS as simulated device.

Any ideas?
best regards,
John Allijn

John Allijn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 65
Joined: Sat Feb 26, 2011 10:02 am

Re: V0.17 - Open heart surgery

Post by John Allijn » Fri Jul 22, 2011 10:18 am

Oh and I tried a put-script with a list button and that works fine:

Code: Select all

 set the uText of group "gSchool" to GeselecteerdeSchool

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Location: UK
Contact:

Re: V0.17 - Open heart surgery

Post by splash21 » Fri Jul 22, 2011 12:08 pm

Thanks for the post, John. I tried recreating your example (with V0.17), and it worked OK :?
(In both IDE and simulator)

Code: Select all

on mouseUp
   
   Answer "Begin getting data"
   
   put the uText of group "firstName" into tFirstName
   put the uText of group "lastName" into tLastName
   put the uText of group "email" into tEmail
   
   answer tFirstName && tLastName && tEmail
   
end mouseUp
DebugSnap1Small.png
In your example, the variable names are sometimes capitalised and sometimes not - does that make a difference on your setup? I'll have another look to see if there's something I've missed!


John.
LiveCode Development & Training : http://splash21.com

lili2012
Posts: 1
Joined: Mon Apr 23, 2012 12:42 pm
Location: Switzerland

Re: V0.17 - Open heart surgery

Post by lili2012 » Mon Apr 23, 2012 12:49 pm

Hi,
I've studied your post and now it looks a very useful plugin to me. Can you tell me that can a selection of iOS and android styled control to get me up and running quickly? And with a growing set of custom contols to drag on to my projects, including native iOS controls (browser, movie player, scroller, text field), I often quickly turn ideas into prototypes and fully functioning apps.

Post Reply

Return to “MobGUI”