Hello, Alexander.

Here is a my quick hack code for Windows Factor.


CONSTANT: wm-keydown-codes
    H{
      { 48 "0" } ! <- added
      { 49 "1" } ! <- added
      { 50 "2" } ! <- added

      { 65 "a" } ! <- added
      { 66 "b" } ! <- added
      { 67 "c" } ! <- added

        { 8 "BACKSPACE" }
        { 9 "TAB" }
        { 13 "RET" }
        { 27 "ESC" }
        { 33 "PAGE_UP" }
        { 34 "PAGE_DOWN" }
        { 35 "END" }
        { 36 "HOME" }
        { 37 "LEFT" }
        { 38 "UP" }
        { 39 "RIGHT" }
        { 40 "DOWN" }
        { 45 "INSERT" }
        { 46 "DELETE" }
        { 112 "F1" }
        { 113 "F2" }
        { 114 "F3" }
        { 115 "F4" }
        { 116 "F5" }
        { 117 "F6" }
        { 118 "F7" }
        { 119 "F8" }
        { 120 "F9" }
        { 121 "F10" }
        { 122 "F11" }
        { 123 "F12" }
        { 190 "PERIOD" } ! <- added
    }


:: key-sym ( wParam -- string/f action? )    ! : -> ::
    ! {
    !     {
    !         [ dup LETTER? ]
    !         [ shift? caps-lock? xor [ CHAR: a + CHAR: A - ] unless 1string f ]
    !     }
    !     { [ dup digit? ] [ 1string f ] }
    !     [ wm-keydown-codes at t ]
    ! } cond ;

    wParam wm-keydown-codes at [ t ] [
       wParam
       {
           {
               [ dup LETTER? ]
               [ shift? caps-lock? xor [ CHAR: a + CHAR: A - ] unless 1string f 
]
             }
             { [ dup digit? ] [ 1string f ] }
             [ wm-keydown-codes at t ]
             } cond
     ] if* ;

:: handle-wm-keydown ( hWnd uMsg wParam lParam -- )
    wParam exclude-key-wm-keydown? [
        wParam key-sym over [
            dup ctrl? alt? xor or [                          ! neccesary?
                hWnd send-key-down
            ] [ 2drop ] if
        ] [ 2drop ] if
    ] unless ;

:: handle-wm-char ( hWnd uMsg wParam lParam -- )
    wParam exclude-key-wm-char? [
        ctrl? alt? xor [
            wParam 1string
!            [ f hWnd send-key-down ]
            [ drop ]
            [ hWnd window user-input ] bi
        ] unless
    ] unless ;




On 2019/03/30 23:05, Alexander Ilin wrote:
> Hello!
> 
>   Nice investigation!
> 
> 30.03.2019, 12:26, "KUSUMOTO Norio" <kusum...@na.rim.or.jp>:
>> It seems to me key-down and key-up events are not desirable, not only in 
>> Windows Factor.
>> For example, on Mac Factor, when the "Q" key is pressed with a shift key, 
>> gesture-logger
>> reports:
>> 
>>   T{ key-down { sym "Q" } }
>>   User input: Q
>>   T{ key-up { sym "Q" } }
>> 
>> I think it should be:
>> 
>>   T{ key-down { mods { S+ } } { sym "q" } }
>>   User input: Q
>>   T{ key-up { mods { S+ } } { sym "q" } }
>   I think you are right, and this would solve a long-standing issue 
> https://github.com/factor/factor/issues/1565
>   I guess nobody had the time to dig into this, so your effort is much 
> appreciated!
> 
>> I changed key-codes which is in 
>> /Applications/factor/basis/ui/backend/cocoa/views/views.factor
>> like this:
>> 
>> CONSTANT: key-codes
>> H{
>>         { 29 "0" } ! <- added
>>         { 18 "1" } ! <- added
>>         { 19 "2" } ! <- added
>> 
>>         { 0 "a" } ! <- added
>>         { 11 "b" } ! <- added
>>         { 9 "c" } ! <- added
>> 
>>         { 71 "CLEAR" }
>>         { 36 "RET" }
>>         { 76 "ENTER" }
>>         { 53 "ESC" }
>>         { 48 "TAB" }
>>         { 51 "BACKSPACE" }
>>         { 115 "HOME" }
>>         { 117 "DELETE" }
>>         { 119 "END" }
>>         { 122 "F1" }
>>         { 120 "F2" }
>>         { 99 "F3" }
>>         { 118 "F4" }
>>         { 96 "F5" }
>>         { 97 "F6" }
>>         { 98 "F7" }
>>         { 100 "F8" }
>>         { 123 "LEFT" }
>>         { 124 "RIGHT" }
>>         { 125 "DOWN" }
>>         { 126 "UP" }
>>         { 116 "PAGE_UP" }
>>         { 121 "PAGE_DOWN" }
>>     }
>> 
>> Then events about "0", "1", "2", "a", "b" and "c" key are desirable for me.
>> 
>> In conclusion, I think all keys which can exist should be added in key-codes.
>   I'll try to see if I can fix the same for the Windows platform.
> 
> ---=====---
>  Александр
> 
> 
--
KUSUMOTO Norio



> 2019/03/30 23:05、Alexander Ilin <ajs...@yandex.ru>のメール:
> 
> Hello!
> 
>  Nice investigation!
> 
> 30.03.2019, 12:26, "KUSUMOTO Norio" <kusum...@na.rim.or.jp>:
>> It seems to me key-down and key-up events are not desirable, not only in 
>> Windows Factor.
>> For example, on Mac Factor, when the "Q" key is pressed with a shift key, 
>> gesture-logger
>> reports:
>> 
>>   T{ key-down { sym "Q" } }
>>   User input: Q
>>   T{ key-up { sym "Q" } }
>> 
>> I think it should be:
>> 
>>   T{ key-down { mods { S+ } } { sym "q" } }
>>   User input: Q
>>   T{ key-up { mods { S+ } } { sym "q" } }
> 
>  I think you are right, and this would solve a long-standing issue 
> https://github.com/factor/factor/issues/1565
>  I guess nobody had the time to dig into this, so your effort is much 
> appreciated!
> 
>> I changed key-codes which is in 
>> /Applications/factor/basis/ui/backend/cocoa/views/views.factor
>> like this:
>> 
>> CONSTANT: key-codes
>> H{
>>         { 29 "0" } ! <- added
>>         { 18 "1" } ! <- added
>>         { 19 "2" } ! <- added
>> 
>>         { 0 "a" } ! <- added
>>         { 11 "b" } ! <- added
>>         { 9 "c" } ! <- added
>> 
>>         { 71 "CLEAR" }
>>         { 36 "RET" }
>>         { 76 "ENTER" }
>>         { 53 "ESC" }
>>         { 48 "TAB" }
>>         { 51 "BACKSPACE" }
>>         { 115 "HOME" }
>>         { 117 "DELETE" }
>>         { 119 "END" }
>>         { 122 "F1" }
>>         { 120 "F2" }
>>         { 99 "F3" }
>>         { 118 "F4" }
>>         { 96 "F5" }
>>         { 97 "F6" }
>>         { 98 "F7" }
>>         { 100 "F8" }
>>         { 123 "LEFT" }
>>         { 124 "RIGHT" }
>>         { 125 "DOWN" }
>>         { 126 "UP" }
>>         { 116 "PAGE_UP" }
>>         { 121 "PAGE_DOWN" }
>>     }
>> 
>> Then events about "0", "1", "2", "a", "b" and "c" key are desirable for me.
>> 
>> In conclusion, I think all keys which can exist should be added in key-codes.
> 
>  I'll try to see if I can fix the same for the Windows platform.
> 
> ---=====--- 
> Александр
> 
> 
> 
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to