THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/08/2012 at 08:06, xxxxxxxx wrote:
Hi everyone!
I'm working on a ToolData Plugin and need to to implement a loop that continues to give me the current mouse position in the editor until I click a mouse button. Basically I want something that behaves like the inverse of a MouseDrag.
The loop that has gotten me closest to what I want so far looks like this:
while not msg[c4d.BFM_INPUT_MOUSELEFT]: #Mouse button clicked?
mouseX = msg[c4d.BFM_INPUT_X]
mouseY = msg[c4d.BFM_INPUT_Y]
print "X: ", mouseX, "Y: ",mouseY
win.BfGetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, msg)#Store Input State to msg
The loop is happening inside the MouseInput() procedure of the ToolData class so 'win' is the current editor view and 'msg' a basecontainer to store the Input Events. So far I didn't have any luck getting this to work. The console outputs the mouse coordinates in screen space, but I can't exit the loop by clicking. Also C4D hangs after the loop has been running for a while.
On a side note, I think there is an error in the documentation because BfGetInputState actually takes two arguments (the flag and a BaseContainer to store the Input Events) and returns a bool instead of a BaseContainer. It's basically the same as c4d.gui.GetInputState(). Took me a while to figure this out, but it didn't help much in the end :)
I hope someone can has a clue how to work this out! Thanks!
Jo