Handling key events



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/11/2008 at 06:27, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   10.5 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi,

    I am currently trying to implement key event listeners inside my Dialog plugin. All is well except for the fact, that the events get handed down to C4D (pressing 'e' e.g. switches to translate inside the plugin AND C4D). I tried to solve this by invoking KillEvent() after handling a keyboard input message but this had no effect.

    What's the correct way to handle keyboard input inside a dialog and not letting handled events slip through to C4D...

    Thanks

    Markus



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/11/2008 at 06:36, xxxxxxxx wrote:

    Please post some code, thanks.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/11/2008 at 06:50, xxxxxxxx wrote:

    Currently we do this:

    in OurDialog::Message:

    > `

      
    \>       if (msg.GetId() == BFM_INPUT)  
    \>       {  
    \>               if(msg.GetLong(BFM_INPUT_DEVICE) == BFM_INPUT_KEYBOARD)  
    \>            {  
    \>                 HandleKeyboardEvents(msg);  
    \>                 this->KillEvents();  
    \>            }  
    \>       }  
    \>  
    

    `

    HandleKeyboardEvents() also gets invoked from an InputEvent() inside a GeUserArea.

    Which simply does this:

    OurDialog::HandleKeyboardEvents(BaseContainer msg) :

    > `

      
    \>  long key = msg.GetLong(BFM_INPUT_CHANNEL);  
    \>  switch(key)  
    \>  {  
    \>  // handle control buttons  
    \>  case 'E':  
    \>       ...switches our ui to translate  
    \>  break;  
    \>  .  
    \>  .  
    \>  .  
    \>  }  
    \>  
    

    `

    What happens is:

    If I press 'e' inside the UserArea it calls OurDialog's HandleKeyboardEvents() and switches our tool to translate.

    If I press 'e' inside our Dialog (but outside the user area) the Dialog's Message function calls HandleKeyboardEvents() and it switches our tool to translate AND switches C4D to translate.

    How do I kill the event from the event queue effectively?

    Thanks

    Markus



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 26/11/2008 at 03:14, xxxxxxxx wrote:

    You have to signal that the key message has been processed. Just return TRUE in that case. Here some working code:

    > \> LONG AsyncDialog::Message(const BaseContainer &msg;,BaseContainer &result;) \> { \>      if (msg.GetId() == BFM_INPUT) \>      { \>           if(msg.GetLong(BFM_INPUT_DEVICE) == BFM_INPUT_KEYBOARD) \>           { \>                HandleKeyboardEvents(msg); \>                return TRUE; //signal that key has been processed \>           } \>      } \>      return GeDialog::Message(msg,result); \> } \> \> void AsyncDialog::HandleKeyboardEvents(BaseContainer msg) \> { \>      LONG key = msg.GetLong(BFM_INPUT_CHANNEL); \>      switch(key) \>      { \>           // handle control buttons \>           case 'E': \>                GePrint("E pressed"); \>                break; \>      } \> } \>

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/11/2008 at 05:20, xxxxxxxx wrote:

    Thanks Matthias!

    That worked perfectly ;)


Log in to reply