On 11/08/2014 at 10:19, xxxxxxxx wrote:

Hi everybody,

I made a plugin, Instance Vault, where a pop up dialog opens up under the mouse position.

It works fine, but if you have 2 monitors, and your c4d main windows is on the second screen, the mouse position you get is wrong, because it´s calculated from the second screen. (resulting in negative values on the first screen). So the dialog opens on the first one from the second, and to the very left on the first.

That´s how I did it:

class instance_menu(c4d.plugins.CommandData) :  
  dialog = None  
  def Execute(self, doc) :  
      if self.dialog is None:  
         self.dialog = pop_menu()  
      res1 = c4d.BaseContainer()  
      c4d.gui.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, res1)  
      mouse_x = res1.GetLong(c4d.BFM_INPUT_X)  
      mouse_y = res1.GetLong(c4d.BFM_INPUT_Y)     
      mouse_x += -160         # offsets to center dialog  
      mouse_y += -70    
      return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC_POPUPEDIT,   
                                        pluginid=INSTANCE_MENU, defaultw=0, defaulth=0,   
                                        xpos=mouse_x, ypos=mouse_y)  

The modal dialog ( DLG_TYPE_MODAL ) without a specified position, behaves like I want it to, but well, I don´t want a modal dialog ;-)
Any ideas how to prevent this?