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
something better than HTMLText of fileds, anyone?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: something better than HTMLText of fileds, anyone?
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.
sp27
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
Re: something better than HTMLText of fileds, anyone?
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.
Re: something better than HTMLText of fileds, anyone?
Thanks, SparkOut! By "developer list" you mean use-livecode@lists.runrev.com or some other resource I don't yet know about?
Re: something better than HTMLText of fileds, anyone?
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.
-
- VIP Livecode Opensource Backer
- Posts: 7266
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: something better than HTMLText of fileds, anyone?
It's likely he also reads the user list. I suspect a question there with his name in it would attract his attention.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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com