Page 1 of 1

Browser with Button on Same Card

Posted: Fri Nov 01, 2013 10:55 pm
by dcpbarrington
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?

Re: Browser with Button on Same Card

Posted: Sat Nov 02, 2013 3:16 am
by Simon
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

Re: Browser with Button on Same Card

Posted: Thu Nov 07, 2013 5:32 pm
by dcpbarrington
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