How to get a mouse click location

Hi Matthias

I'm trying to implement some GUI updates that allow people to drag a point or edge around with the mouse, I wonder is there a way on the API that let me obtain the mouse click location?

Thank you very much!


  • Yes there is. But it's not a single "get_mouse_click" function, but rather an API. You'll need to create a "Plugin", register it and wrap your function into the core of the plugin.

    You will find some documentation about this concept here:

    Plugins are a different approach to user-entry driven features, but eventually they are concept the whole KLayout application is built upon and by using Plugins you will find your code integrates smoothly into the application.

    There have been a couple of discussions here (e.g. Expectations are to have a simple function, but in fact the API is asynchronous. A Plugin can request exclusive access to the mouse, but only after registering a "mode" which means the application will decide when to grant exclusive control. If you do not consider that in the design of your application, it will be difficult to implement atop of KLayout's API.


Sign In or Register to comment.