http://qs1969.pair.com?node_id=908563


in reply to Re^2: Is there a way to make Prima widgets accept double byte characters?
in thread Is there a way to make Prima widgets accept double byte characters?

I was reluctant to get inside CIJK because I somehow thought that I have to have a real chinese keyboard, but I gave it a go and installed Chinese layout and lo, I could type unicode! Miracle ))

Well anyway, yes, WM_CHAR was an easy spot, but strangely enough it only conveyed question mark symbols, never the real chars. Same with WM_IME_CHAR. Finally I found a working method, from GTK - they catch WM_IME_COMPOSITION and explicitly extract the chars by calling ImmGetCompositionStringW.

I've tried that too, but after typing a test char the Chinese IME died and refused to come up :) Again, thinking that usually IME-aware apps use wide-char win32 API, I've changed calls to RegisterClass and CreateWindow to their wide-char counterparts, and that seemingly helped.

So I've committed the change, but the problem is, I have no knowledge of Chinese, and my semi-random key strokes that produce a seemingly ok chiniese character doesn't mean that the input is accepted correctly. It seems so, but I'm not 100% sure. So if anyone's willing, you're more than welcome grab the latest Prima from github ( https://github.com/dk/Prima ) and see if that works for your favourite language and IME.

  • Comment on Re^3: Is there a way to make Prima widgets accept double byte characters?

Replies are listed 'Best First'.
Re^4: Is there a way to make Prima widgets accept double byte characters?
by ZJ.Mike.2009 (Scribe) on Jun 08, 2011 at 11:45 UTC
    @dk, thank you for committing the change. I really appreciate it :) But unfortunately the InputLine widget still doesn't work for me :(

    I downloaded the dk-Prima-e3c6fd6.zip file, unzipped it and ran the ms_install.pl file. I got Prima installed successfully

    But when running a Prima app, Perl gives me the following warnings:

    Bareword "km::Unicode" not allowed while "strict subs" in use at C:/Perl/site/li b/Prima/InputLine.pm line 279. Compilation failed in require at C:/Perl/site/lib/Prima/MsgBox.pm line 42. BEGIN failed--compilation aborted at C:/Perl/site/lib/Prima/MsgBox.pm line 42. Compilation failed in require at (eval 72) line 1. BEGIN failed--compilation aborted at (eval 72) line 1. BEGIN failed--compilation aborted at E:\vb.pl line 27.

    Okay, that's not a real problem. I commented out the use strict; line in the InputLine.pm and Edit.pm and running my Prima app again. This time the Prima showed up and then I tried to enter some Chinese characters in the InputLine widget but it didn't work. The widget still refused to accept any IME input. By any I mean I can select English words through the IME but English words from the IME can't be entered in the InputLine widget either. I'm not a GTk user and I don't know if I can enter IME characters with GTk. But both wxPerl and Perl Tk accept IME input from my Chinese system. It's just weird. I'll give it some more tries. Anyway thank you for the effort.
      Hi,

      Can you write me to dmitry@karasik.eu.org? This way we could solve the problem more productively. Also, can you tell which IME did you install? I've installed one called "Chinese Traditional Array 6.0" something, chances are that if you used something else, I should try it too.

      Also, it wouldn't work the way you installed it - you need to run

      perl Makefile.PL dmake dmake install
      (assuming you've running strawberry perl, some other make or nmake otherwise)
        While you're fixing stuff, how to do multiple apps?
        #!/usr/bin/perl -- use strict; use warnings; Main( @ARGV ); exit( 0 ); sub Main { ShowPrima(); ShowPrima(); } sub ShowPrima { require Prima ; require Prima::Buttons; require Prima::Application; $::application ||= Prima::Application-> create( qw' name Prima '); my $mw = Prima::MainWindow->create( text => 'Hello world!', size => [ 200, 200], ); $mw-> insert( Button => centered => 1, text => 'Hello world!', onClick => sub { $::application-> close }, ); #~ Prima->run; $::application ->go; } __END__ Illegal object reference passed to Component.get_components at C:/perl +/site/5.12.2/lib/MSWin32-x86-multi-thread/Prima/Classes.pm line 193.

        Thank you, Dmitry!

        It finally works although with many problems. But it's on the right track :) LOL

        I added extra two lines of code which I mentioned earlier in this thread and then as you suggest I did the "makefil.pl dmake dmake install" 3-step installation rather than just running ms_install.pl.
        case WM_IME_CHAR: ev. key. code = mp1;
        It now works but with a lot of problems. Okay, I'll write to the mail address you specified with more details.

        Thank you again!