Unicode and revBrowser: "selected" property and callback messages

Mike Bonner bonnmike at gmail.com
Sun May 29 09:06:37 EDT 2011


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
>



More information about the use-livecode mailing list