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

    Mouseposition-Screenposition

    Scheduled Pinned Locked Moved PYTHON Development
    1 Posts 0 Posters 163 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 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.
      http://www.fractality.de/plugins.html

      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?

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