Languages, keyboard maps and ask dialogs

Devin Asay devin_asay at byu.edu
Thu Sep 14 18:16:07 EDT 2006


Lars,

On Sep 14, 2006, at 1:56 PM, Lars Brehmer wrote:

> I seem to have one last language-character problem begging for a  
> solution.
>
> No one came up with a way to switch to the correct the keyboard map  
> when a field is clicked in or otherwise active, so I guess I will  
> have to live with that. I did find out something interesting  
> through experimentation.  At least with my app running in Windows,  
> it DOES actually switch when a Russian field is clicked in, but  
> when an Estonian field is clicked in, it switches to the English  
> keyboard map.  I assume this is because the machine I use was  
> purchased in the US and there seems to be no way to ged rid of that  
> keyboard.  If I delete it and make the default map Estonian and  
> click in ANY field with Roman/Latin mapping, the English keyboard  
> magically reappears and is selected.  I will try this on a locally  
> bought machine that doesn't have English as the default keyboard  
> map, which just might work. If notl, at the least the Russian  
> fields seem to work.  I suppose that most people who use different  
> mappings on a regular basis are used to this problem, so I guess in  
> the end it is not a big deal.  On the Mac, it never switches to  
> Russian.  Not really a problem because 98% of potential users here  
> have Windows machines, just a little frustrating for me working  
> with it :-(

I've dealt with this problem, and found a solution that worked for  
me. In the field that I want to automatically switch to Russian, I use:

on selectionChanged
   if the promptphrase of fld "kwizfld" is in me then
     doStartTypingStuff
   end if
end selectionChanged

on keyDown which
   if the cleanfield of me then -- this is set to true when the field  
is emptied
     send "selectionChanged" to me
   end if
   pass keyDown
end keyDown

on doStartTypingStuff -- this just inits the field for the new language
   set the cleanfield of me to false
   select the text of me --because I want to replace what was there  
before

   if the platform is "MacOS" then put the macFont of this stack into  
tFont
   else put the winFont of this stack into tFont

-- This particular fld can be English sometimes, Russian other times
-- depending on the value of the listLanguage custom prop
   if the listLanguage of this cd is "Russ" then
     set the textFont of the selectedChunk to tFont
   else
-- this is what makes it work
     set the textFont of the selectedChunk to (tFont&",ru")
   end if
   put empty into me
end doStartTypingStuff

This has worked reliably for me on both Mac OS X and Windows. The  
macFont and winFont custom properties are just the name of the  
preferred font for that platform, Verdana for Mac, Arial for Windows.
>
> Now to the last problem.  No matter what I try with useUnicode,  
> uniencode, unidecode etc. I can't get an ask dialog to work with  
> Russian.  All I want is to ask a user's name and put it into a field.
>
> The textFont of the field is Geneva,Russian
>
> So far the ask dialog is in Estonian.  It asks for your name, and  
> when you use the Russian keyboard map and type in a name, it shows  
> up fine, in Russian in the name field.  But I'd prefer to ask in  
> Russian, but can't get Russian in the ask dialog.  I have tried  
> storing the question in a separate field, and as a custom property  
> and in both cases tried every combination of uniEncode and  
> uniDecode that works in other aspects of this project.  I saw  
> Sarah's post about the Danish .lproj being useful.  Is this where I  
> should be looking, because I have no idea what that is, how it  
> works or how to implement it.  Is there anything else i should be  
> trying?  I am once again really stumped here!

Oddly enough, I've been able to get this to work with answer dialogs,  
but not ask dialogs. For ask dialogs you do this:

Type the Russian text into a field: Пишите имя и  
фамилию. (Don't know if this will come thru email.)
put the htmlText of the field (into the message box). This is what  
you get:
<p><font face="Geneva CY"  
lang="ru">Пишите</font><font  
face="Geneva CY"> </font><font face="Geneva CY"  
lang="ru">имя</font><font face="Geneva CY"> </ 
font><font face="Geneva CY" lang="ru">и</font><font  
face="Geneva CY"> </font><font face="Geneva CY"  
lang="ru">фамилию</ 
font><font face="Geneva CY">.</font></p>

Copy and paste the htmlText from the message box into a custom prop  
of the button that triggers the dialog, say, the promptText of btn  
"dialogOpener".
Call the answer dialog like this: answer the promptText of me.
The answer dialog is in Russian!

You'd expect the same thing to work with answer, but it doesn't. If  
you try the same thing, it just shows the htmlText. :-(
I suspect you'll have to roll your own ask dialog using a modal  
substack.

HTH

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list