Pointer coordinates inside a UserArea [SOLVED]
On 01/04/2015 at 14:39, xxxxxxxx wrote:
I have the following code:
def Message(self, msg, result) : if msg.GetLong(c4d.BFM_INPUT_CHANNEL)==c4d.BFM_INPUT_MOUSELEFT: # the mouse is being pressed self.dragging=True mouseX1=msg.GetLong(c4d.BFM_INPUT_X) mouseY1=msg.GetLong(c4d.BFM_INPUT_Y) localPos=self.Global2Local() self.i_x1=mouseX1+localPos['x'] self.i_y1=mouseY1+localPos['y'] while True: # dragging the mouse bc = c4d.BaseContainer() if gui.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, bc) : if bc.GetLong(c4d.BFM_INPUT_CHANNEL)==c4d.BFM_INPUT_MOUSELEFT: mouseX2=bc.GetLong(c4d.BFM_INPUT_X) mouseY2=bc.GetLong(c4d.BFM_INPUT_Y) localPos=self.Global2Local() self.i_x2=mouseX2+localPos['x'] self.i_y2=mouseY2+localPos['y'] self.Redraw() if not bc.GetBool(c4d.BFM_INPUT_VALUE) : break self.dragging=False return gui.GeUserArea.Message(self, msg, result)
The starting coordinates (stored in i_x1 and i_y1) are calculated correctly.
But the coordinates of the pointer while the mouse button is being pressed (stored in i_x2 and i_y2) are not being calculated correctly. However I'm using the exact same method to calculate both.
If I use Screen2Local instead of Global2Local (in the calculations of the coordinates while the mouse button is being pressed), the i_x2 coordinate is calculated correctly but the i_y2 coordinate has a negative displacement.
Can't they be calculated the same way?
Please, please, please, someone help me.
On 01/04/2015 at 14:43, xxxxxxxx wrote:
Ok, solved it!!! :-D
It was fast.
I just replaced the:
if gui.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, bc) :
if self.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, bc) :
On 02/04/2015 at 03:24, xxxxxxxx wrote:
You should do this in InputEvent(), not Message()