GtkMenu::popup

GtkMenu::popup

void popup([ GtkWidget parent_menu_shell , [ GtkWidget parent_menu_item , [ GtkMenuPositionFunc pos_function , int button, int activate_time]]]);

The popup() method looks fairly intimidating at the outset, but is actually quite straightforward to use.

The first thing to be aware of is that the parent_menu_shell and parent_menu_item parameters would generally only be used internally, to associate the popped-up menu with a given GtkMenuShell descendant, or GtkMenuItem, or both. In a freestanding popup menu, both parameters should be passed as null.

The third parameter concerns the positioning of the popup menu, and has as its default the position of the mouse pointer. In order to set a different position, you will need to set up a function that will return an array of the co-ordinates, and call it from the pos_function parameter.

The fourth parameter refers to the mouse button emitting the "button-release-event" that will be compared with the button emitting the "button-press-event" in order to set the timer in the final parameter. This only works if you happen to be triggering the popup function with a button press, and the button pressed and button released are the same - in all other situations, the time element is ignored. However, setting the button parameter to 1 or 3 will speed up the deactivation when the left or right mouse button is released respectively, regardless of the callback event.

The final parameter, activate_time, sets the time conditions for the menu's deactivation. If you have used a button press event and ensured that the initial press and later release have the same valid integer value, then setting the timer to 0 will make the menu disappear as soon as the user releases the mouse-button that triggered it. The safest setting for this parameter is $event->time - this being a setting that all GdkEvent structures share; it causes the popup menu to react as you'd expect it to, and won't spring any surprises if you duplicate or otherwise adapt the original callback event.

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.