Problem with input of localized characters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with input of localized characters

Michal
This post was updated on .
Hi, I have a problem with writing some Czech characters ('ě', 'č' for example in Workspace).
Writing such a character in Workspace then behaves the same way as a shortcut.

Using the 'č' causes a jump to a new line.
Using the 'ě' opens menu with a list ('Do it' 'Print it' etc.)

Can you please advice me a solution to be able to write characters mentioned above? I have a font set to "Calibri" which displays these characters correctly. There are no other settings I could find. I use Pharo 3.0 on the Windows platform.


BingLiang [via Smalltalk]

Hi,Michal

I use Pharo 3 or 4 in Chinese windows. I happned to the similar problem.

HandMorph>>generateKeyboardEvent: evtBuf

Pls check the bold part.

generateKeyboardEvent: evtBuf
        "Generate the appropriate mouse event for the given raw event buffer"
 
        | buttons modifiers type pressType stamp charCode keyValue keyEvent |
        stamp := evtBuf second.
        stamp = 0 ifTrue: [stamp := Time millisecondClockValue].
        pressType := evtBuf fourth.
        pressType = EventKeyDown
                ifTrue: [
                        type := #keyDown.
                        lastKeyScanCode := evtBuf third].
        pressType = EventKeyUp ifTrue: [type := #keyUp].
        pressType = EventKeyChar ifTrue: [
                type := #keystroke].
        modifiers := evtBuf fifth.
        buttons := modifiers bitShift: 3.
        keyValue := evtBuf third.
        charCode := evtBuf sixth.

        "Adjustments to provide consistent key value data for different VM's :
        - charCode always contains unicode code point.
         - keyValue contains 0 if input is outside legacy range "
        "If there is no unicode data in the event, assume keyValue contains a correct (<256) Unicode codepoint, and use that"
        (charCode isNil
                or: [charCode = 0])
                ifTrue: [charCode := keyValue].
        "If charCode is not single-byte, we definately have Unicode input. Nil keyValue to avoid garbage values from some VMs."
        charCode > 255 ifTrue: [keyValue := 0].




        type = #keystroke
                ifTrue: [combinedChar
                        ifNil: [
                                | peekedEvent |
                                peekedEvent := Sensor peekEvent.
                                (peekedEvent notNil
                                        and: [peekedEvent fourth = EventKeyDown])
                                        ifTrue: [
                                                (CombinedChar isCompositionCharacter: charCode)
                                                        ifTrue: [
                                                                combinedChar := CombinedChar new.
                                                                combinedChar simpleAdd: charCode asCharacter.
                                                                (combinedChar combinesWith: peekedEvent third asCharacter)
                                                                        ifTrue: [^nil].
                                                                ]]]
                        ifNotNil: [
                                (combinedChar simpleAdd: charCode asCharacter)
                                        ifTrue: [charCode := combinedChar combined charCode].
                                combinedChar := nil]].

        self flag: #fixme.
        "This piece of code handles the creation of scrolling events. When a scroll is done by the user, the VM forwards a keystroke event with the up/down key. So we reconvert it to a MouseWheelEvent in that case."
       
        (type = #keystroke and: [(buttons anyMask: 16)
                        and: [charCode = 30 or: [charCode = 31]]])
                ifTrue: [^MouseWheelEvent new
                                        setType: #mouseWheel
                                        position: lastMouseEvent cursorPoint
                                        direction: (charCode = 30 ifTrue: [#up] ifFalse: [#down])
                                        buttons: buttons
                                        hand: self
                                        stamp: stamp].

        keyEvent := KeyboardEvent new
                setType: type
                buttons: buttons
                position: self position
                keyValue: keyValue
                charCode: charCode
                hand: self
                stamp: stamp.
        keyEvent scanCode: lastKeyScanCode.
        ^keyEvent



May be it could work.

Cheers!

Liangbing



Thanks for the tip, it works.
I'm surprised there that the check is not part of base code, but has to be added in particular.