Unicode and revBrowser: "selected" property and callback messages

Slava Paperno slava at lexiconbridge.com
Sun May 29 09:56:02 EDT 2011


Great, I'll try that, too, Mike--thanks. I couldn't have thought of it, but
of course passing parameters in the URL is the most natural thing to do...
In my case there's no URL, because I load these "Web pages" locally by
assigning the HTML string from the database to the revBrowser's "htmltext"
property, but that can be gotten around. I'll let you know.

Slava. 

> -----Original Message-----
> From: use-livecode-bounces at lists.runrev.com [mailto:use-livecode-
> bounces at lists.runrev.com] On Behalf Of Mike Bonner
> Sent: Sunday, May 29, 2011 9:27 AM
> To: How to use LiveCode
> Subject: Re: Unicode and revBrowser: "selected" property and callback
> messages
> 
> Actually, just had a different thought. May have seen this in the
> forums or
> here before, so not sure its my idea, but..
> 
> There is a callback browserBeforeNavigate. If you set your javascript
> to try
> and navigate to a jump link URL on doubleclick of a word, then it will
> be
> sent to browserBeforeNavigate.
> 
> So, if you attempt to go to "
> http://yourcurrent.webpage.com/mypage#theWordToFind" which should
> trigger
> browserbeforenavigate, giving you an easily parsable string to get the
> word
> from.  And I believe, as long as the web page base url is exactly the
> same
> as the current page other than the #wordtofind, no need to stop any
> actual
> navigation.
> 
> I didn't test this using javascript to initiate the navigation, I just
> made
> a quick document with manual links like so. <a href=test1>test1</a>
> Set up
> 3 of these in the page, clicked, caught them with browserbeforenavigate
> and
> it seemed to work.  Seems that it should when javascript initiated
> also, but
> untested there so your mileage may vary.
> 
> 2011/5/29 Mike Bonner <bonnmike at gmail.com>
> 
> > Can't help with the unicode part, but if you turn on advanced
> messages in
> > revbrowser, you can catch clicks.
> >
> > revbrowserset sBrowserId,"messages",true
> > From the dictionary:
> > *Note: The "advanced" callback messages are: browserClick, browserOut
> and
> > browserOver. These messages are only sent when the "messages"
> property is
> > set to true. The other callback messages are always sent.*
> >
> > In your web page, you could have a click place the word in a holding
> > variable, in livecode you could time track the clicks (since there is
> no
> > browserDoubleClick as far as I can tell) and if a 2nd click occurs
> quickly
> > enough then use revbrowsercallscript to get the value.  Or you could
> handle
> > things mostly on the javascript side, catch a doubleclick and set a
> the
> > holding var, then wait for livecode to again use revbrowsercallscript
> to
> > call a javascript function that will return the clicked word.  2nd
> option is
> > probably better.
> >
> > 2011/5/29 Slava Paperno <slava at lexiconbridge.com>
> >
> >> Thanks for thinking about this, Jacqueline. The problem persists.
> >>
> >> I said:
> >> > > When a user double-clicks a word in the revBrowser window, I
> would
> >> like
> >> a message
> >> > to be sent by revBrowser to the stack, with that word as a
> parameter.
> >>
> >> And you said:
> >> > Your best bet is to put in a feature
> >> > request in the QCC, but of course you probably don't want to wait.
> >>
> >> I also said:
> >> > > As a slightly different approach, I thought I might tell the
> user to
> >> > select a word in the Web page that is displayed by revBrowser, and
> then
> >> > click a button in the card. That would be less intuitive for the
> user,
> >> but
> >> > still practical. So I put this script in the button's mouseUp
> handler:
> >> > >
> >> > > get revBrowserGet(gBrowserID, "selected")
> >> > > put uniEncode(it, "UTF8") into locSelectedText
> >> > > set the unicodeText of field "BrowserSelection" of this card to
> >> locSelectedText
> >> > >
> >> > > The last line of this script works fine when the selected text
> is
> >> > > English. When it is Russian, a question mark is received in each
> >> character of
> >> > > "it."
> >>
> >> And you said:
> >> > The first thing I'd try is not uniEncoding the string at all. If
> the
> >> > browser is showing it correctly it may already be UTF-16, and any
> >> > further conversion would corrupt it. If that's true, then the
> method I
> >> > posted before should be all you need. Just grab the string,
> prepare the
> >> > field to accept unicode, and set the unicodetext of the field to
> the
> >> > string.
> >>
> >> And I said: I have tried all sorts of combinations of uniEncoding
> and
> >> uniDecoding everything around this process. When I examine the
> English
> >> characters in the string returned by the "selection" property, I
> conclude
> >> that it is in a single-byte charset. For example, when the string
> АБВABC
> >> is
> >> selected in revBrowser display, this call:
> >>
> >> get rebRbrowserGet(gBrowserID, "selected")
> >> answer char 1 to 6 of it
> >>
> >> displays this:
> >>
> >> ???ABC
> >>
> >> That tells me that "it" is not in UTF-16. If it is indeed in ANSI
> (or,
> >> worse
> >> yet, ASCII), then the question marks are entirely natural: as I
> said,
> >> applications that are non-Unicode compliant have always done that.
> But
> >> since
> >> the Web page in revBrowser has the meta tag that says:
> >>
> >> meta http-equiv="Content-Type" content="text/html;charset=UTF-8"
> >>
> >> The browser should know it is a double-byte text. The question is,
> does
> >> its
> >> "selected" property know that? If you have evidence this is
> otherwise,
> >> please let me know.
> >>
> >> You also said:
> >> > If that doesn't work...
> >> >    put uniEncode(it,"Unicode") into locSelectedText
> >>
> >> That is different from what I have done only in that you suggest
> "Unicode"
> >> where I use "UTF8". Changing that to your version hasn't made a
> >> difference.
> >> I think the problem is the content of the "selected" property--but
> I've
> >> only
> >> been playing with LC for a couple of weeks, so I can't trust myself.
> >>
> >> You kindly said:
> >> > And if that doesn't work, I can try to find out why.
> >>
> >> I would appreciate any other pointers... Perhaps I am thinking in
> the
> >> Director box, andthere is a natively LC way to achieve what I need?
> >>
> >> Slava
> >>
> >> > Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> >> > HyperActive Software           |     http://www.hyperactivesw.com
> >>
> >>
> >>
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> use-livecode at lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> >
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode






More information about the use-livecode mailing list