Αναδυόμενο μενού περιεχομένων
Πολλά άτομα χρειάζονται να υλοποιήσουν δεξιό πάτημα σε μενού περιεχομένων για την TreeView, έτσι θα εξηγήσουμε πώς να το κάνετε αυτό εδώ για να σας εξοικονομήσουμε κάποιο χρόνο. Πέρα από ένα ή δύο σημεία, είναι παρεμφερές με το κανονικό μενού περιεχομένων, όπως περιγράφηκε στο κεφάλαιο μενού.
- 10.7.1. Χειρισμός button_press_event
10.7.1. Χειρισμός button_press_event
To detect a click of the right mouse button, you need to handle the button_press_event signal, and check exactly which button was pressed. Because the TreeView normally handles this signal completely, you need to either override the default signal handler in a derived TreeView class, use connect_notify() or use connect(slot, /* after= */ false). You probably also want to call the default handler before doing anything else, so that the right-click will cause the row to be selected first.
Αυτό παρουσιάζεται στο παράδειγμα αναδυόμενου προσαρμοσμένου μενού.