RETURN & ENTER in Unicode

Devin Asay devin_asay at byu.edu
Wed Apr 2 19:49:34 CEST 2014


On Apr 2, 2014, at 11:18 AM, Richmond <richmondmathewson at gmail.com> wrote:

> So; here I am bu**ering around in my Devawriter Pro
> 
> [ http://andregarzia.on-rev.com/richmond/dwriterpro.html ]
> 
> which is in what I, slightly pompously, call its 3rd System Development
> Life-Cycle . . .
> 
> Anyway . . .
> 
> Inside a socking great rawKeyDown Case statement one of the possibilities runs a bit like this:
> 
> case 65293
>    set the useUnicode to true
>    set the unicodeText of the selectedText to (numToChar(13) & numToChar(10))
>    select after the selectedText
> break
> 
> now 65293 is the raw key code for the 'Return' key [ the one above the right-hand SHIFT key ],
> so, in theory, when an end-user hits that key they should end up with a carriage return in the
> text field: BUT they don't.
> 
> Just to really confuse the issue, when an end-user hits the 'Enter' key [ over on the right, on
> those keyboards that have a number pad ] they get a carriage return: this seems to make
> no sense at all considering that the raw key code for the 'Enter' key is 65421.
> 
> So; just "for a laugh" I threw this into the soup:
> 
> case 65421
>    set the useUnicode to true
>    set the unicodeText of the selectedText to (numToChar(13) & numToChar(10))
>    select after the selectedText
> break
> 
> and that blocked the 'Enter' key as well.
> 
> This tells me that my rawKeyDown for those keys is doing "sweet FA", and merely serving to block
> them.
> 
> Of course the easy thing to do is just to remove the case 65293 code so that the
> 
> default
>  pass rawKeyDown
> 
> at the end of the switch statement just lets the OS strut its funky stuff with the 'Return' key
> rather than attempting to over-ride it in the app.
> -------------------------------------------------------------------------
> 
> BUT; this is not entirely satisfying, and I wonder if anyone can tell me what I should
> have in my case 65293 code instead of
> 
> (numToChar(13) & numToChar(10))
> 
> to get a carriage return?

Richmond,

LiveCode uses ASCII 10 internally for the end-of-line delimiter. 13+10 is the Windows line delimiter, but you should not have to bother with that, unless you're saving the text in your field to an external file using put into URL "binfile:…" If you use URL "file:…" the line-ending conversion happens automatically. But I suspect that since you're dealing with unicode text you're using bilefile:

Regards,

Devin

Devin Asay
Learn to code with LiveCode University
http://university.livecode.com






More information about the use-livecode mailing list