the mouseText and Unicode

Slava Paperno slava at lexiconbridge.com
Sat Jun 18 08:32:20 EDT 2011


A very interesting discussion! Thanks, Richmond--I tried all the same
tricks, with the same baffling results you're reporting. First work always
works.

Mark--I've used you suggestion about "the unicodeText of selection" to great
advantage in a different context (when the user has selected some text
manually), but I can't figure out how to use it here. "select the clickText"
and "select the mouseText" work correctly only "half the time": In my sample
string, clicking words 1, 2, 3, or 4 selects word 1. Clicking words 5, 7, 9,
and 11 selects the word I click, but clicking other words doesn't.

Maybe that's because I haven't followed your first direction, "set the
unicodeText of fld x to the clipboarddata["unicode"]". I'm not sure how I
would do that. My texts never come from the clipboard. They are either typed
in the field or retrieved from a database or read from text files on the
local disc.

You also said "if you're desperate, delete that extra null byte." That's
intriguing. I don't care about PPC machines. But I can't find any null bytes
in my fields. I expected a null byte to be added to each Roman character,
e.g. 0x00AF. But when I use "put byte N of field X" for the Roman
characters, I can't find a null byte anywhere. Roman characters seem to be
represented by one byte in my two-bytes fields. I know this doesn't sound
right, so I must be missing something.

Slava

> -----Original Message-----
> From: use-livecode-bounces at lists.runrev.com [mailto:use-livecode-
> bounces at lists.runrev.com] On Behalf Of Mark Schonewille
> Sent: Saturday, June 18, 2011 6:24 AM
> To: How to use LiveCode
> Subject: Re: the mouseText and Unicode
> 
> Hi Slava,
> 
> Instead of simply pasting the text into LiveCode, do the following:
> 
> set the unicodeText of fld x to the clipboarddata["unicode"]
> 
> Now you can do this:
> 
> on mouseDown
>   select the clickText
>   set the unicodeText of fld 2 to the unicodeText of the selection
> end mouseDown
> 
> or whatever you would like to do with the clickText. This works fine on
> Intel processors, I'm not sure wha happens if you try this on a PPC
> processor.
> 
> --
> Best regards,
> 
> Mark Schonewille
> 
> Economy-x-Talk Consulting and Software Engineering
> Homepage: http://economy-x-talk.com
> Twitter: http://twitter.com/xtalkprogrammer
> KvK: 50277553
> 
> New: Download the Installer Maker Plugin 1.6 for LiveCode here
> http://qery.us/ce
> 
> On 18 jun 2011, at 08:07, Slava Paperno wrote:
> 
> > 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.
> >
> > Thanks, Jacqueline!
> >
> > Slava
> 
> 
> _______________________________________________
> 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