Adding Code to created buttons on iPad

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
SteveHanlan
Posts: 80
Joined: Fri Jul 09, 2010 6:28 pm

Adding Code to created buttons on iPad

Post by SteveHanlan » Tue Dec 21, 2010 9:49 am

Hi

New to LiveCode and loving it

I created a grid of buttons based on stored data.
How do I add code to each button (mouseUp)?

Alternatively, how can I detect which button was pressed on a stack?

Also, how can I get a stack to size smaller than a full ipad? Every stack or card I use resizes to full screeen

thanks in advance for your help

Steve

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Adding Code to created buttons on iPad

Post by Klaus » Tue Dec 21, 2010 11:31 am

Hi Steve,

1. to detect the button that has been clicked, you can check "the target" in a generic "mouseup" handler in the card or stack script!

Stack script:

Code: Select all

on mouseup
   put the name of the target into tTarget
   put the short name of the target into tTargetName
   ## will be something line: buton "mybutton1" or filed "name of field"
 
   ## We only want check for buttons:
   if word i oftTaget <> "button" then
    exit mouseup
   end if

  ## Now we can "react" on the different bvutons clicked:
  switch tTargetName
   case "button666"
    ## do yourt thing with this button
   break
   case "button 555"
      ### etc.
   break
 end switch
end mouseup
2. Although adding code to objects via scripts, this is not recommended, since there are runtime limitations for this!
You can only add/set scripts with a maximum of 10 statements in a standalone.
So a "generic" handler would suit better in this situation, or using and setting behaviours for newly created objects.

3. Stack size.
Since iOS apps are in fact "one window only" app, I am afraid it is not possible to have smaller sized stacks,
since there is no desktop or whatever on iDevices and thus you always get a fullscreen display.
Someone please correct me if I'm wrong.


Best

Klaus

Post Reply