It looks like you're new here. If you want to get involved, click one of these buttons!
Hi, Matthias,
Thank you for providing KLayout and keeping adding feature to it.
I am writing a plugin to use KLayout as a wafermap GUI (typically, used to extract chip ids based on mouse operation on layout and apply specific operation using these selected chipids) and having two questions:
1. How to add pop-up menu when right-clicking the layout view area?
2. The function behind the mouse event (e.g. left click and drag-selection) under selection mode is charming and is there a way to re-use these functions inside a mouse event (with other code) attached to a new plugin?
Best Regards
Comments
Hi!
You could install event handler on
LayoutView.on_selection_changed
and do some additional processing. Main window menu command may be installed in.lym
file and it may enable/disable event handler functionality.Hi, Eugene,
Thank you for your feedback.
Since the code is running under Plugin, do you mean to check the status of
LayoutView.on_selection_changed
after eachmouse_button_released_event
? is there a better way to install this event?I see the example from SiEPIC on installing a menu under main window. It could work as an alternative way while there is some inconvenience since the mouse has to moved up and look for the right menu there.
Hi!
No, you just monitor selection changes in event handler assigned to
LayoutView.on_selection_changed
, so you don't need to care about low-level mouse events.Python code looks like:
@tiboy
The concept of KLayout does not include a right-click context menu. The mouse buttons are reserved for zoom, select and pan/zoom.
You can basically implement a right-click menu with a plugin, but doing so puts you outside the basic UI concept and you have to implement that yourself based on the Qt features.
The selection drag box isn't available currently for reuse - if you want to implement such a feature you need to instantiate a marker (https://www.klayout.de/doc-qt5/programming/application_api.html#k_10) which represents the drag box. Upon mouse press you create it, on mouse move you modify it and on mouse release (or when leaving the function) you erase it. This is basically what the selection feature does as well.
Matthias
Here is some code for a plugin that drags a box:
Enjoy, Matthias
Thank you, Matthias and Eugene. Your reply and code are very helpful.