Qualifiers



  • On 14/03/2013 at 00:35, xxxxxxxx wrote:

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

    ---------
    Hi Folks,
     
    I'm trying to get the SHIFT key while it's pressed for a GeUserArea, in the InputEvents member. I've tried all sorts of variations of the following:

       BaseContainer Qualifier = NULL;  
    if(GetInputState(BFM_INPUT_KEYBOARD, BFM_INPUT_CHANNEL, Qualifier))   
    {  
      GePrint("Qual called..");  // this sometimes prints  
      if(Qualifier.GetLong(BFM_INPUT_QUALIFIER) & QSHIFT)  
      {  
          GePrint("SHIFT pressed..");  // this never prints  
          return TRUE;  
      }  
    }
    

    I can get other keys to work - just none of the qualifiers. Where have I gone wrong?
     
    Cheers,
     
    WP.



  • On 14/03/2013 at 06:24, xxxxxxxx wrote:

    Hi,

    Don't forget that qualifiers are only called in combination with the mouse.
    And you don't need to call GetInputState() because InputEvents() already gives you a message container for the event.
    So you can simply write:

    if (msg.GetLong(BFM_INPUT_QUALIFIER) & QSHIFT)
    {
        GePrint("SHIFT pressed");
        return TRUE;
    }
    

    Also, this line is frightening 😄:

    BaseContainer qualifier = NULL;
    

    The variable is allocated on the stack. It's not a pointer and you should never initialize it with NULL:

    BaseContainer qualifier;
    


  • On 14/03/2013 at 17:01, xxxxxxxx wrote:

    Thanks Yannick,
     
    however that code runs when either the mouse buttons, or any other keyboard button, is pressed. The shift key will be used in conjunction with the mouse (to select some items) but don't we need to be able to catch the shift key on it's own first?
     
    Thanks for the tip on the allocation of variables also. I wasn't aware of that. I've gone through and cleaned up a few of my NULL variables now - cheers!
     
    WP.



  • On 14/03/2013 at 17:15, xxxxxxxx wrote:

    hey,

    have you tried c4d.BFM_ACTION_VALUE ? some time ago i had somewhat a similar
    problem (the user pressing enter in dialog). not sure if it helps, but  here is the 
    link to the posting.

    https://plugincafe.maxon.net/topic/6804/7552_gedialogmessage-return-value-&PID=31327#31327



  • On 15/03/2013 at 01:30, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    however that code runs when either the mouse buttons, or any other keyboard button, is pressed.

    Take a look at SDKGradientArea::InputEvent() in the async.cpp example. You can test for qualifier input after the BFM_INPUT_MOUSELEFT test.

    I'm using a similar approach in SceneHookData::MouseInput(). The mouse button and qualifier key are reliably detected when clicking in the viewport.


Log in to reply