Rawkey events and string gadgets
  • Just looking around
    evenmore
    Posts: 8 from 2012/2/6
    From: N. Ireland
    Hi
    I have a few problems porting my working MUI interface (on MUI 3.8) to MUI 4 on MorphOS.

    My problem is with the rawkey event and string gadgets. I find that when I activate a string gadget on MUI 4, the keypresses are still being processed by the rawkey handler. The result is you cannot type text into the string. Yet it works no problem on MUI 3.8. I can't figure it out.

    I would be grateful for any advice anyone is able to give on this. Thanks! 8-)
  • »15.03.12 - 20:38
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 2984 from 2003/3/5
    From: Canada
    Care to provide some code showing how you process the raw events?
  • »15.03.12 - 21:00
    Profile Visit Website
  • Just looking around
    evenmore
    Posts: 8 from 2012/2/6
    From: N. Ireland
    Thanks for your help. Then IDCMP rawkey is set up in the mSetup function...

    PROC mSetup(cl:PTR TO iclass,obj:PTR TO object,msg:PTR TO muip_handleinput)
    IF doSuperMethodA(cl,obj,msg)=NIL THEN RETURN FALSE
    Mui_RequestIDCMP(obj, IDCMP_MOUSEBUTTONS OR
    IDCMP_RAWKEY OR
    IDCMP_VANILLAKEY)
    ENDPROC MUI_TRUE

    The mHandleInput function calls the RAWKEY function...

    PROC mHandleInput(cl:PTR TO iclass, obj:PTR TO object, msg:PTR TO muip_handleinput)
    ...
    IF msg.imsg
    selectdummy:=msg.imsg.class
    qual := msg.imsg.qualifier
    code := msg.imsg.code

    SELECT selectdummy
    CASE IDCMP_RAWKEY; handlerawkeyevent(qual, code)
    CASE IDCMP_VANILLAKEY; handlevanillakeyevent(qual, code)
    ...
    ENDSELECT
    ENDPROC doSuperMethodA(cl,obj,msg)

    And then the handlerawkeyevent() function handles what is actually pressed...

    PROC handlerawkeyevent(qualifier, code)
    DEF value
    IF qualifier AND (IEQUAL_ALT)
    SELECT code
    CASE CURSOR_UP_KEY
    ...
    ENDSELECT
    ...
    ENDIF
    ENDPROC

    Am I missing something when it comes to MUI4? Thanks again!
  • »15.03.12 - 21:46
    Profile Visit Website
  • Just looking around
    evenmore
    Posts: 8 from 2012/2/6
    From: N. Ireland
    Should mHandleInput check what object the event was triggered by maybe?
  • »15.03.12 - 21:53
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Tcheko
    Posts: 510 from 2003/2/25
    From: France
    You are using deprecated technic for rawkey handling.
    Quelque soit le chemin que tu prendras dans la vie, sache que tu auras des ampoules aux pieds.
    -------
    I need to practice my Kung Fu.
  • »15.03.12 - 22:16
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1516 from 2003/2/24
    From: Finland
    That is, RequestIDCMP() is deprecated and it would be better use MUIM_Window_AddEventHandler/MUIM_Window_RemEventHandler methods.

    (String.mui have changed in MUI4 so it could have some effect in your application.)

    [ Edited by itix 16.03.2012 - 10:41 ]
    1 + 1 = 3 with very large values of 1
  • »16.03.12 - 08:20
    Profile
  • Just looking around
    evenmore
    Posts: 8 from 2012/2/6
    From: N. Ireland
    Thanks very much for your helpful suggestions! I will look again at this.
  • »16.03.12 - 20:44
    Profile Visit Website
  • Just looking around
    evenmore
    Posts: 8 from 2012/2/6
    From: N. Ireland
    Still no joy. I have removed the RequestIDCMP code and replaced it with the proper AddEventHandler code. Still the same problem occurs. When I specify RAWKEY and VANILLAKEY events in the event handler node, string input stops working. Right and left arrow keys do still work in the strings for some reason, but typing ordinary letters in the string activates my event handler code instead. Yet it seems to work ok in MUI 3.8.

    I am wondering if it is anything to do with ECX MUI modules not being compatible with MUI 4? I tried altering the event handler priority, and a number of other things. But still the same problem. Event handler code is being handled before the active object. Any ideas? Thanks for your help. :-?
  • »18.03.12 - 18:13
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 2984 from 2003/3/5
    From: Canada
    Well... it could be that your handler has a higher priority than the one of the string gadget. I suppose you might want a lower pri handler.
  • »18.03.12 - 18:59
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1516 from 2003/2/24
    From: Finland
    Quote:


    When I specify RAWKEY and VANILLAKEY events in the event handler node, string input stops working.



    Oh... you shouldnt use VANILLAKEY in MUI. MUI classes are relying on IDCMP_RAWKEY and when you add IDCMP_VANILLAKEY to IDCMP flags some classes stop working. This is also case in MUI 3 with other text input classes.

    So you should use RAWKEY only and using MapRawKey() get vanilla key code. In MorphOS 2/MUI 4 you can also get unicode so you dont have to do conversion anymore:

    switch (IntuiMessage->Class)
    {
    case IDCMP_RAWKEY:
    ULONG ucs4_keycode = getv(IntuiMessage, IMSGA_UCS4)
    break;
    }
    1 + 1 = 3 with very large values of 1
  • »19.03.12 - 06:20
    Profile
  • Just looking around
    evenmore
    Posts: 8 from 2012/2/6
    From: N. Ireland
    That's fantastic! Thanks very much for all your help guys. It was the VANILLAKEY event that was causing the problem. I have managed to fix it using your MapRawKey suggestion. Thanks again! :-)
  • »20.03.12 - 14:24
    Profile Visit Website