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

    Pointer coordinates inside a UserArea [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 325 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

      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.

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

        On 01/04/2015 at 14:43, xxxxxxxx wrote:

        Ok, solved it!!! 😄
        It was fast.
        I just replaced the:

        if gui.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, bc) :

        with

        if self.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, bc) :

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

          On 02/04/2015 at 03:24, xxxxxxxx wrote:

          You should do this in InputEvent(), not Message()

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