userarea and mouse hoover

On 08/08/2014 at 08:03, xxxxxxxx wrote:

In my CommandPlugin I have a mixed dialog with an userarea and normal dialog fields.
Now I want to know the mouse coordinates, when the mouse is over the userarea.
I can do that with Message() and read out the mouse coordinates.

class Area(gui.GeUserArea) :
   
    def DrawMsg(self, x1, y1, x2, y2, msg) : 
        global bmpXY
        self.DrawSetPen(c4d.COLOR_BG)            #Set the Background Color
        self.DrawRectangle(x1, y1, x2, y2)
        
        self.DrawBitmap(bmpXY, 0,0, 300,300, 0,0, 300,300, c4d.BMP_NORMAL)
  
    def Message(self, msg, result) :
        if msg.GetId() :
    
            self.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, msg)   #Mouse over UA and left button not clicked
            if msg.GetLong(c4d.BFM_INPUT_VALUE)==0: 
                mouse_x=msg.GetLong(c4d.BFM_INPUT_X)
                mouse_y=msg.GetLong(c4d.BFM_INPUT_Y)
                #print "x+y: ", mouse_x, mouse_y
  
        return self.Message(msg, result)
        #return GeUserArea.Message(self, msg, result)

The manual tells me how to do this, but it is not working for me.
Both return self.Message(msg, result) and return GeUserArea.Message(self, msg, result)
are not working for me.

How should I approach this?

GeUserArea.Message(self, msg, result)[](file:///D:/Users/pgrooff/Documents/pim/c4d/Python%20Help%20R15/help/modules/c4d.gui/GeUserArea/index.html?highlight=message#GeUserArea.Message)

Override this function if you want to react to more messages than covered by the other functions. Normally this is not necessary. Be sure to include a call the parent version of this function, [Message()](file:///D:/Users/pgrooff/Documents/pim/c4d/Python%20Help%20R15/help/modules/c4d.gui/GeUserArea/index.html?highlight=message#GeUserArea.Message):

def Message(self, msg, result) :
    if msg.GetId() :
        pass #do something
        return True

    return GeUserArea.Message(self, msg, result)

On 10/08/2014 at 05:14, xxxxxxxx wrote:

Solved.
Of course it should be return gui.GeUserArea.Message(self, msg, result)

On 10/08/2014 at 06:24, xxxxxxxx wrote:

Now I'm getting a Runtime error: max recursion depth exceeded while calling a Python object.
Is the place where I'm calling message() perhaps wrong?

Or is it that I call gui.GeUserArea.Message from within my UA class Area(gui.GeUserArea)?

Here my structure:

- class Area(gui.GeUserArea) :

def DrawMsg(self, x1, y1, x2, y2, msg) : 
        global xValue
        global yValue

self.DrawSetTextCol(c4d.Vector(1,1,1), c4d.Vector(0,0,0))      
        self.DrawText("Hello", xValue, yValue, flags=c4d.DRAWTEXT_STD_ALIGN)   
        return

def Message(self, msg, result) :
        global xValue
        global yValue
     
        self.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, msg)  
        if msg.GetLong(c4d.BFM_INPUT_VALUE)==1:

mouseX=msg.GetLong(c4d.BFM_INPUT_X)                     #Get the global mouse coords.
            mouseY=msg.GetLong(c4d.BFM_INPUT_Y)
            localPos = self.Global2Local()                          #Convert the mouse positions from global to local
            mouseX += localPos['x']                                 #The mouse's local coords.
            mouseY += localPos['y']
           
            xValue = mouseX                                  
            yValue = mouseY

self.Redraw()

return gui.GeUserArea.Message(self, msg, result)

On 10/08/2014 at 08:12, xxxxxxxx wrote:

Originally posted by xxxxxxxx

Or is it that I call gui.GeUserArea.Message from within my UA class Area(gui.GeUserArea)?

This was indeed incorrect.
Moving message() to the dialog part solved the issue!