the mouseText and Unicode
slava at lexiconbridge.com
Sat Jun 18 02:07:51 EDT 2011
Aha! The idea of using "the number of words" is brilliant.
Unfortunately, the word boundaries don't "quite" work, and I think it's for
the same reason: I think the mouseCharChunk reports bytes, not characters.
It is Unicode-smart in some ways: when you click a non-Roman letter, it
returns "char N to N+1 of field X." When you click a Roman letter in a
double-byte field it returns "char N to N of field X."
In this string, for example:
Саша, Наташа, Митя, Роберт, Robert, Jeffrey, and Соня Петрова, Слава
Паперно, Лора Баглай, Макс Паперно
clicking on the first letter in word 4 returns 3 for the number of words.
This is what I have in the mouseUp handler of the field:
put word 2 of the mouseCharChunk into locStart
put locStart && the number of words in char 1 to locStart of me
Clicking on the space between word 1 and word 2 (the space after the first
comma) displays 10 for locStart. It is indeed byte 10, but if the entire
field were treated as double-byte text, it should be 11. So each Russian
letter is counted as two bytes and two characters, but the comma is counted
as one byte and one character. This screws up my math.
Strangely, clicking anywhere other than the first letter of the fourth word
in that sample string returns the correct word position.
So I'm still in the dark.
> -----Original Message-----
> From: use-livecode-bounces at lists.runrev.com [mailto:use-livecode-
> bounces at lists.runrev.com] On Behalf Of J. Landman Gay
> Sent: Saturday, June 18, 2011 12:34 AM
> To: How to use LiveCode
> Subject: Re: the mouseText and Unicode
> On 6/17/11 11:07 PM, Slava Paperno wrote:
> > Is there an equivalent to the mouseText, or the mouseChunk, or the
> > mouseCharChunk that is Unicode-aware? Or some ingenious way to
> retrieve the
> > word that the user clicked?
> Does the "word" delimiter work? If so, you could try this in the field:
> on mouseUp
> get word 2 of the mouseCharChunk
> put the number of words in char 1 to it of me into tWordNum
> put word tWordNum of me into tWordClicked
> -- do something with tWordClicked
> end mouseUp
> 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:
More information about the Use-livecode