{curl 3.0 applet} {curl-file-attributes character-encoding = "shift-jis"} {import * from CURL.GUI.IME} {define-class public TestView {inherits View, InputMethodClient} field td:TextDisplay = {TextDisplay} {constructor public {default td:TextDisplay, ...} {construct-super.View input-method-enabled? = true, ...} set self.supports-inline-mode? = true set self.td = td {self.request-key-focus} set self.input-method-enabled? = true } {method public open {on-key-press e:KeyPress}:void {super.on-key-press e} {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 self.td.value = out-str } } ||文字入力の開始 {method public open {on-start-composition-event e:StartCompositionEvent }:void {super.on-start-composition-event e} } ||文字の入力 {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 } } ||文字入力の終了 {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} } } {let g-td:TextDisplay = {TextDisplay width={make-elastic}, height={make-elastic}, font-size=24pt, font-weight=FontWeight.bold, font-family="MS ゴシック" } } {value let v:View = {TestView g-td, width = 15cm, height = 2cm, {Frame width = {make-elastic}, height = {make-elastic}, margin=8pt, g-td }, {on WindowClose do {exit} } } {v.show} }