When an object is created, the result is inserted in the study widget. When selecting an item (or more than one) in the study and clicking with the mouse right button, the popup definition is activated. There are two possibilities:
_xdata
python module (the one coded in
AAA_xdata.py
file if the current module is AAA
).
Once the container is founded, the popup definition calls
customPopup
on the container. If the container is a
python module, customPopup
is a function and the signature
is:
customPopup(parent, popup, nodes)
customPopup
is
a class method and the signature is:
customPopup(cls, parent, popup, nodes).
QPopupMenu
object and nodes is a list containing the selected objects.
Using customPopup
is a good way to customize popups but you
have to know qt a little to activate the correct qt signals when items
are selected. If you don't want to know about qt, you can use the
second way to intercept the popups. Indeed, the default implementation
of customPopup
calls the getPopupItems
facility and
connect the qt signals. The signature of getPopupItems
is
getPopupItems(parent, nodes)
getPopupItems
is a class method and the signature is:
getPopupItems(cls, parent, nodes).
getPopupItems
must return a list of string to be inserted
in the current popup menu. When an item from getPopupItems
is
activated, the container.popupActivated
facility is activated.
If the container is a python module, popupActivated
must be
a function with signature
popupActivated(parent, target, nodes),
popupActivated
is a class method and the signature is:
popupActivated(cls, parent, target, nodes),
parent
and nodes
are the parent qt widget and
the selected object, target
is the string representing the
popup item which has been activated.
The default implementation of XObject.getPopupItems
return
a list of string based on the __object__xmethods__
list
defined in the class.