something better than HTMLText of fileds, anyone?

Interested adding compiled externals from LiveCode and third parties to your LiveCode projects? This is the place to talk about them.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sp27
Posts: 135
Joined: Mon May 09, 2011 3:01 pm

something better than HTMLText of fileds, anyone?

Post by sp27 » Sat May 21, 2011 7:47 pm

I have a large database of relatively small texts in basic HTML format (including very basic tables), and I need to display these texts in a card. Cellpadding, cellspacing, and borders in tables must be supported.

The HTMLText property of fields in LC supports a rich collection of text styles, but not HTML tables.

How would you display such HTML text in a card? The user needs to be abke to adjust the font size of the text in the card, and my scripts need to be able to detect which word in the text the user clicked.

Any tips would be appreciated.

sp27

sp27
Posts: 135
Joined: Mon May 09, 2011 3:01 pm

Re: something better than HTMLText of fileds, anyone?

Post by sp27 » Sun May 22, 2011 3:48 am

Here is the complete answer to this wish, thanks to Mike Bo***

First, we close the loaded instances of revBrowser, then we instantiate a new one and display a blank Web page from disk, and then we set the revBrowser's property HTMLText to the HTML text we want to display (in my case, it is retrieved from a database). I think displaying a blank Web page is necessary because I don't know how to instantiate a revBrowser w/o giving it a valid URL.

Code: Select all

on unloadRevBrowser
   --closes all running instances of revBrowser, if any
   local locBrowsersLoaded
   
   put revBrowserInstances() into locBrowsersLoaded 
   repeat with i = 1 to the number of items in locBrowsersLoaded
      revBrowserClose item i of locBrowsersLoaded
   end repeat
   
end unloadRevBrowser
   
on loadRevBrowser
   --instantiates revBrowser, stores its ID in gBrowserID, and displays an empty Web page from disc
   
   global gHomePath --folder where this stack file lives
   local locHTMLFilePathName --path to the blank HTML file we'll be displaying
   
   global gBrowserID
   local locBrowsersLoaded 
   
   --close the loaded browser(s), if any
   unloadRevBrowser
   
   put gHomePath & "blank.htm" into locHTMLFilePathName
   
   local tWindowId
   put the windowid of this stack into tWindowId
   
   put revBrowserOpen(tWindowId, "file:" & locHTMLFilePathName) into gBrowserID
   if gBrowserID is not an integer then
      answer error "Error opening browser."
      exit loadRevBrowser
   end if
   
   revBrowserSet gBrowserID, "showborder", true
   --the browser pane replaces a field called "HTMLTextLiteral" that shows some directions
   revBrowserSet gBrowserID, "rect", the rect of field "Directions" of this card
   
end loadRevBrowser

on showMyHTML
   local locMyHTML --an HTML-formatted text retrieved form a database or wherever
  if not (("<html" is in locHTMLText) and ("</html>" is in locHTMLText) and ("<body" is in locHTMLText) and ("</body>" is in locHTMLText)) then
      answer warning "Your text does not contain a valid HTML document."
      
      --close the loaded browser(s), if any
      unloadRevBrowser
      
      exit showMyHTML
   end if

   --assign the HTML text to the current instance of revBrowser
   revBrowserSet gBrowserID, "htmltext", locHTMLText
end showMyHTML

on mouseUp
   loadRevBrowser
   showMyHTML
end mouseUp
sp27

SparkOut
Posts: 2857
Joined: Sun Sep 23, 2007 4:58 pm

Re: something better than HTMLText of fileds, anyone?

Post by SparkOut » Sun May 22, 2011 10:43 am

If you can get a message to Tim Bobo who is very active on the developer list, he has been developing and making available a "webkitfield" library for this sort of thing. He's done some amazing stuff with it, very high quality. I wouldn't dream of directly passing his contact information on, so I'm not sure what the best way to attract his attention is.

sp27
Posts: 135
Joined: Mon May 09, 2011 3:01 pm

Re: something better than HTMLText of fileds, anyone?

Post by sp27 » Sun May 22, 2011 4:30 pm

Thanks, SparkOut! By "developer list" you mean use-livecode@lists.runrev.com or some other resource I don't yet know about?

SparkOut
Posts: 2857
Joined: Sun Sep 23, 2007 4:58 pm

Re: something better than HTMLText of fileds, anyone?

Post by SparkOut » Sun May 22, 2011 4:51 pm

No, that's the "user" list. Access to the "developer" list is a chargeable addition to the Livecode programme of licences, unless you have it bundled with the Livecode Complete licence, for instance. Hence I was hesitant about handing over contact information. It's tricky, because I can't tell you to go and ask on the developer list, and I can't go bandying about other people's contact info. The availability of his work is appropriate to the environment of the developer list, but though I cannot speak for him, I would also imagine he would be happy for you to obtain it as well. But it's not my place to give it away on his behalf.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7257
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: something better than HTMLText of fileds, anyone?

Post by jacque » Sun May 22, 2011 6:07 pm

SparkOut wrote:It's tricky, because I can't tell you to go and ask on the developer list, and I can't go bandying about other people's contact info.
It's likely he also reads the user list. I suspect a question there with his name in it would attract his attention.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Using Externals”