An alternative:

On 19/02/2013, at 12:39 PM, Jonathan Cooper <drd...@gmail.com> wrote:

> Or, failing that, to
> have Livecode automatically set the keyboard layout as soon as the field is
> opened?

That may not be always reliable, as in some systems - like the Mac - the user 
has to explicitly 'enable' the keyboard layout (in System Preferences), for it 
to be available. There is, however, a more 'low-tech' solution. 

Many years ago, before people were able to easily type accented letters on the 
internet, it was common to see an 'alternative' Esperanto spelling, which used 
'x' - a letter that doesn't exist in Esperanto - where an accent should be 
used. So, for instance, instead of typing "ĉ", the user would type "cx". 
Instead of typing "ŭ", the user would type "ux". 

I remember, that I developed an online forum that scanned for the appropriate 
letter combinations in user posts (cx, gx, hx, jx, sx and ux), and 
automatically replaced them with the 'correct', accented characters: ĉ, ĝ, ĥ, 
ĵ, ŝ and ŭ. 

In Livecode, this kind of 'search-and-replace' could be done quite easily in a 
field script - either on 'textChanged', or on 'closeField'. I imagine something 
like this would do:

on closeField
 // because we cannot hard-code unicode characters into our script
 // it's easier to use the 'htmlText' property to deal with unicode chars:
 local tHTMLContent
 put the htmlText of me into tHTMLContent
 
 // replace all the x-letters with their equivalent html entities:
 replace "cx" with "&#265;" in tHTMLContent
 replace "CX" with "&#264;" in tHTMLContent
 replace "gx" with "&#285;" in tHTMLContent
 replace "GX" with "&#284;" in tHTMLContent
 replace "hx" with "&#293;" in tHTMLContent
 replace "HX" with "&#292;" in tHTMLContent
 replace "jx" with "&#309;" in tHTMLContent
 replace "JX" with "&#308;" in tHTMLContent
 replace "sx" with "&#349;" in tHTMLContent
 replace "SX" with "&#348;" in tHTMLContent
 replace "uxx" with "&#365;" in tHTMLContent -- we don't want to have problems
 replace "UXX" with "&#364;" in tHTMLContent -- with English words like 
'auxiliary'...
 
 // put the replaced text back in the field:
 set the htmlText of me to tHTMLContent 
end closeField

This already provides a workable solution. For an more polished user 
experience, you can try developing a script that is more forgiving when the 
user mixes upper- and lower-case 'x's, like "Cx" and "cX". You can also try to 
develop a script that would do the replacing on 'textChanged' rather than on 
'closeField', but you will then have to use 'the selectedChunk' and some basic 
maths in order not to loose the user's insertion point place in the text, as 
you replace the characters.

I hope this helps!

Kind regards,

--
Igor Couto
Sydney, Australia





_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to