Browser with Button on Same Card

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Browser with Button on Same Card

Post by dcpbarrington » Fri Nov 01, 2013 10:55 pm

I have a simple card that has a header with two button and a region that is defined to display a Native Browser Control. Here is the code to set up the browser control.

Code: Select all


function InitializeBrowser pBrowserArea
   put wordOffset("stack",pBrowserArea) into tWord
   put word 1 to (tWord -2) of pBrowserArea into browserAreaID
   
   put the rect of browserAreaID into tBrowserRect
   
   put the windowid of this stack into tWindowId
   
   put "http://www.google.com" into tURL
   
   if environment() is "mobile" then
      mobileControlCreate "browser", "mainScroll"
      put the result into sBrowserID
      mobileControlSet sBrowserID, "rect", tBrowserRect
      mobileControlSet sBrowserID, "visible", true
      mobileControlSet sBrowserID, "url", tURL
      --set the layer of button "HomeButton" to top
   else
      put revBrowserOpen(tWindowID, tURL) into tBrowserID
      if tBrowserId is not an integer then
         answer "Error opening browser: " & tBrowserID
         exit InitializeBrowser
      end if
      
      put tBrowserId into sBrowserID
      
      revBrowserSet sBrowserID, "showborder", true
      revBrowserSet sBrowserID, "rect", tBrowserRect   
  end if
   
end InitializeBrowser

The Browser area is defined by a graphic that is 480 x 600 with the top at 200. The card is 480 x 800

The header has two LiveCode Button with very simple mouseUp scripts. They are combined with a text string into a Group and are at the very top of the page.

The button with this script works fine.

Code: Select all

on mouseUp
   launch url "http://www.google.com"
end mouseUp
The button on the right with this script doesn't work on Android, but does work on Windows.

Code: Select all

on mouseUp
   go to card "Welcome"
end mouseUp
Based on other posts, the native browser control takes over the entire card, unless you define the area, which I have done.

I just need a way for the user to go back to the main program. Any suggestions?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Browser with Button on Same Card

Post by Simon » Sat Nov 02, 2013 3:16 am

Hi dcpbarrington,
Do you have "revBrowserClose tBrowserId" on your card (maybe in the closeCard)?
You could try moving it into the button before the "go to card "Welcome"" that might help.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Re: Browser with Button on Same Card

Post by dcpbarrington » Thu Nov 07, 2013 5:32 pm

Simon,

You were DEAD ON. I changed the Browser CleanUp function from the closeCard message handler to the HOME button and it resolved the issue.

Thank you so much for your guidance.

dcpbarrington

Post Reply