Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Handling key events

    Scheduled Pinned Locked Moved SDK Help
    5 Posts 0 Posters 342 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              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 😉

              1 Reply Last reply Reply Quote 0
              • First post
                Last post