Hi Maekawa-san,

Though my Curl environment is version 3 (not version 4), basic
strategy to use IME (input method) might be same.

First of all, when a graphical object requires an in-line mode IME,
the object should be ancestor (child) of InputMethodClient class.
I,e, in your case, TestView or parent View class should be ancestor of
InputMethodClient.  As Curl built in View is not ancestor of
InputMethodClient, your own class TestView should be declared as child
of InputMethodClient such like shown below.

    {import * from CURL.GUI.IME}

    {define-class public TestView {inherits View, InputMethodClient} ...

also, in constructor, tell Curl that your class TestView is
responsible for displaying the composition string and visually
indicating the current composition state.  This can be done by
following setter,

    set self.supports-inline-mode? = true

Next, in order to get a Kanji-string from IME, your class TestView has
to define a set of static handlers like followings,

      || Start IME conversion
      {method public open {on-start-composition-event
                              e:StartCompositionEvent
                          }:void
        {super.on-start-composition-event e}
        || your trap code here
      }

      || IME input
      {method public open {on-composition-change-event
                              e:CompositionChangeEvent
                          }:void

        {super.on-composition-change-event e}

        {if e.string.size > 0 then
            set self.td.value = e.string
        }
      }

      || Finish IME input
      {method public open {on-composition-result-event
                              e:CompositionResultEvent
                          }:void
        {super.on-composition-result-event e}
        set self.td.value = {format "done (%s)", e.string}
      }
    }

For a complete code (for version 3), see attachment.

Hope this helps to solve your problem.

Best Regards,
Steven Y.


From: Takanobu Maekawa <[EMAIL PROTECTED]>
Subject: about Input Method
Date: Sat, 24 Jun 2006 18:09:20 +0900

> Hi all,
> thanks you for all advices.
> 
> Recently I've been trying to migrate some tools ,
> which doesn't always need to install into local PC,
> to Curl platform.
> 
> So, at first, for experiment, now I'm trying to make
> a terminal emulater which will be combined with telnet
> and ssh protocol.
> 
> As you see the bellow experimental detached applet,
> I'm trying to make the keyboad inputs transformed from
> unicode to shift-jis character.
> 
> Because most UNIX servers in Japan are using shift-jis or euc-jp
> encoding, the client terminal must send the appropriate encoded
> characters according to the server's encoding mode.
> 
> At this moment, in my plan, the method of sending encoded characters
> from a curl cient terminal to a server will be done with converting
> the default input character (it's unicode, which is curl's standard)
> to the other encoded chdracter.
> 
> But with the bellow code, I can not even input multibyte characters
> like "あ"(a Japanese character) from keyboad with Japanese IME
> (Japanese Input Method program).
> I wonder that maybe IME cannot be enabled.
> 
> Please tell me how to solve this problem or general usage rules of
> Input Method in Curl platform.
> 
> -------------------------------------------------------------------
> {curl 4.0 applet}
> {curl-file-attributes character-encoding = "shift-jis"}
> 
> {import CURL.UTIL.ELASTIC}
> 
> {define-class public TestView {inherits View}
> 
>   field td:TextDisplay = {TextDisplay}
> 
>   {constructor public {default td:TextDisplay, ...}
> 
>     {construct-super input-method-enabled? = true, ...}
> 
>     set self.td = td
> 
>     {self.request-key-focus}
>     set self.input-method-enabled? = true
> 
>     {self.add-event-handler
>         {on e:KeyPress do
>             {if e.normal? then
>                 let s:String ={String e.value}
>                 let byteVec:ByteVec = {ByteVec max-size=2}
>                 let char-encoding:CharEncoding =
> {get-character-encoding-by-name  "shift-jis"}
>                 let (in:int,out:int)={encode-characters
>                                          s,
>                                          byteVec,
>                                          char-encoding}
> 
>                 let out-str:String = {format "%s (",s}
> 
>                 {for i:int=1 to out do
>                     set out-str = out-str & {format "0x%02x ", byteVec[i
> - 1]}
>                 }
>                 set out-str = out-str & ")"
>                 set td.value = out-str
>             }
>         }
>     }
>   }
> }
> 
> {let g-td:TextDisplay = {TextDisplay
>                             width={make-elastic},
>                             height={make-elastic},
>                             font-size=24pt,
>                             font-weight=FontWeight.bold,
>                             font-family="MS ゴシック"
>                         }
> }
> 
> {TestView
>     g-td,
>     width = 15cm, height = 2cm,
>     {Frame
>         width = {make-elastic},
>         height = {make-elastic},
>         margin=8pt,
>         g-td
>     },
>     visibility = "normal",
>     {on WindowClose do
>         {exit}
>     }
> }
> ----------------------------------------------------------------
> 
> regards.
> --maekawa
> 
> 
> *******************************************
> To unsubscribe from this list, send a mail to:
> mailto:[EMAIL PROTECTED]
> To contact a human list administrator, send a mail to:
> mailto:[EMAIL PROTECTED]
> To recieve a list of other options for this list, send a mail to:
> mailto:[EMAIL PROTECTED]

Attachment: sample.curl
Description: Binary data

*******************************************
To unsubscribe from this list, send a mail to:
mailto:[EMAIL PROTECTED]
To contact a human list administrator, send a mail to:
mailto:[EMAIL PROTECTED]
To recieve a list of other options for this list, send a mail to:
mailto:[EMAIL PROTECTED]

Reply via email to