Time for action – setting up the tab navigation

Before getting into the process of making the Browser card, we need to set up the items that are shared across all the cards in the app. The following steps will help you do this:

  1. We'll use MobGUI again to make life easier. Select revMobGUI by navigating to the Development | Plugins submenu. Also, open the Project Browser from the LiveCode Tools menu to observe the stack structure as it develops.
  2. Create a new Mainstack, set its name to WebScraper, and save it someplace.
  3. In these instructions, we'll use iPhone in portrait orientation, but feel free to use iPad or an Android size for the card. Either select iOS7 and 320x480 in the MobGUI window or your preferred options.
  4. As you did in the Time for action – using MobGUI to remember layouts for us section in Chapter 3, Building User Interfaces, use the MobGUI tools to add a Navbar and click on Snap to top of the card window, a Tab-bar with Snap to bottom of the card window, and Bg colors for both. Note that a MobGUI card and behavior controls are added to the project automatically when MobGUI controls are added to the Mainstack.
  5. Drag a LiveCode field control to the NavBar and label it NavBar. Format it as you like.
  6. Drag out a Button control from the MobGUI palette and duplicate it four times. Select all the five buttons and select Align Objects from the Inspector. Align their tops and distribute them across the card. Drag the five buttons to the Tab-bar that you just created and adjust their size and position as desired.
  7. Name the five buttons as Browser, Links, Text, Media, and Keepers. Do this by setting the Label entry in the Inspector palette.
  8. Edit the script of each button and in the mouseUp handler, add the following lines to leave the handler looking like this:
    on mouseUp
      put the short Name of me into tTabText
      set the Text of field "NavBar" to tTabText
      go card tTabText
      init
    end mouseUp
  9. From the Edit menu, and select Select All | Group Selected from the Object menu.
  10. Select the group, and in the Basic Settings menu of the regular LiveCode Object Inspector, give the group, the name Common and check the Behave like a background button.
  11. Set the name of the card to Browser.
  12. Make a new card and name it Links. Note that the grouped buttons appear on the new card.
  13. Do the same for three more cards that are to be named Text, Media, and Keepers.
  14. Go to Standalone Application Settings, choose iOS or Android as the platform you want to try, select the appropriate target from the Development menu, and perform a Test.
  15. Click on or touch the five tab buttons and you should see that the name of the NavBar field has changed.

What just happened?

By naming the buttons and cards the same, we were able to go to the five cards using the script attached to the group. Also, we used the button script to set the name of the NavBar to match the name of the card we had jumped to. The init line will come on its own as we write the card scripts.

Note

Do not use the same name with the same type of control on the same card. Your script may end up operating on the wrong control.

The Browser card

We'll now add a few controls and scripts to the first card to create the following mini web browser:

The Browser card

The native browser control has many properties, actions, and messages associated with it. You can view both the iOS Release Notes and the Android Release Notes at the following websites:

http://downloads.livecode.com/livecode/5_5_5/LiveCodeNotes-5_5_5-iOS.pdf

http://downloads.livecode.com/livecode/5_5_5/LiveCodeNotes-5_5_5-Android.pdf

Additional updates on support documents can be found at the following :

http://livecode.com/blog/2013/10/18/6-1-2-brings-ios-7-support/

For our application though, we only need a few of LiveCode's abilities.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset