Handling Mouse Drag

On 19/05/2016 at 01:08, xxxxxxxx wrote:

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

Hi Folks,

I'm trying to create a drag feature that's similar to the viewport rectangle mouse drag (but in my own user area). The viewport rectangle drag doesn't seem to result in much CPU, but it also doesn't effect anything else in the interface if the mouse goes over something else.

I can initiate a drag from my user area's InputEvent(), but if I drag the mouse outside of the dialog, the dialog no longer receives any messages. If I initiate a loop inside the InputEvent(), then I get a 100% CPU rate on one core.

How is something like the viewport rectangle drag handled?


On 19/05/2016 at 05:16, xxxxxxxx wrote:


using MouseDrag() does not increase the CPU load that much during such a drag. What exactly are you doing?

// start mouse drag  
while (MouseDrag(&deltaX, &deltaY, &channels) == MOUSEDRAGRESULT_CONTINUE)  
 if (!GetInputState(BFM_INPUT_MOUSE, BFM_INPUT_MOUSELEFT, state))  
 if (state.GetInt32(BFM_INPUT_VALUE) == 0)  
 // print something when the mouse has moved  
 if(deltaX != 0.0 || deltaY != 0.0)  
     GePrint("Mouse Drag");  

Best wishes,