type Gtk_Menu_Record is new Gtk.Menu_Shell.Gtk_Menu_Shell_Record with private;
type Gtk_Menu is access all Gtk_Menu_Record'Class;
type Gtk_Menu_Detach_Func is access procedure (Attach_Widget : access Gtk.Widget.Gtk_Widget_Record'Class; Menu : access Gtk_Menu_Record'Class);
type Gtk_Menu_Position_Func is access procedure (Menu : access Gtk_Menu_Record'Class; X : out Gint; Y : out Gint);
Accel_Group_Property : constant Glib.Properties.Property_Object;
Accel_Path_Property : constant Glib.Properties.Property_String;
Active_Property : constant Glib.Properties.Property_Int;
Attach_Widget_Property : constant Glib.Properties.Property_Object;
Monitor_Property : constant Glib.Properties.Property_Int;
Tearoff_State_Property : constant Glib.Properties.Property_Boolean;
Tearoff_Title_Property : constant Glib.Properties.Property_String;
Bottom_Attach_Property : constant Glib.Properties.Property_Int;
Left_Attach_Property : constant Glib.Properties.Property_Int;
Right_Attach_Property : constant Glib.Properties.Property_Int;
Top_Attach_Property : constant Glib.Properties.Property_Int;
Arrow_Placement_Property : constant Glib.Properties.Property_Enum;
Arrow_Scaling_Property : constant Glib.Properties.Property_Float;
Double_Arrows_Property : constant Glib.Properties.Property_Boolean;
Horizontal_Offset_Property : constant Glib.Properties.Property_Int;
Horizontal_Padding_Property : constant Glib.Properties.Property_Int;
Vertical_Offset_Property : constant Glib.Properties.Property_Int;
Vertical_Padding_Property : constant Glib.Properties.Property_Int;
Signal_Move_Scroll : constant Glib.Signal_Name := "move_scroll";
procedure Initialize
( | Widget | : access Gtk_Menu_Record'Class); |
function Get_Type return Gtk.Gtk_Type;
procedure Set_Active
( | Menu | : access Gtk_Menu_Record; |
Index | : Guint); |
function Get_Active
( | Menu | : access Gtk_Menu_Record) return Gtk.Menu_Item.Gtk_Menu_Item; |
procedure Set_Tearoff_State
( | Menu | : access Gtk_Menu_Record; |
Torn_Off | : Boolean); |
function Get_Tearoff_State
( | Menu | : access Gtk_Menu_Record) return Boolean; |
procedure Set_Title
( | Menu | : access Gtk_Menu_Record; |
Title | : UTF8_String); |
function Get_Title
( | Menu | : access Gtk_Menu_Record) return UTF8_String; |
procedure Reorder_Child
( | Menu | : access Gtk_Menu_Record; |
Child | : access Gtk.Widget.Gtk_Widget_Record'Class; | |
Position | : Gint); |
procedure Attach
( | Menu | : access Gtk_Menu_Record; |
Child | : access Gtk.Menu_Item.Gtk_Menu_Item_Record'Class; | |
Left_Attach | : Guint; | |
Right_Attach | : Guint; | |
Top_Attach | : Guint; | |
Bottom_Attach | : Guint); |
procedure Popup
( | Menu | : access Gtk_Menu_Record; |
Parent_Menu_Shell | : Gtk.Menu_Shell.Gtk_Menu_Shell := null; | |
Parent_Menu_Item | : Gtk.Menu_Item.Gtk_Menu_Item := null; | |
Func | : Gtk_Menu_Position_Func := null; | |
Button | : Guint := 1; | |
Activate_Time | : Guint32 := 0); |
procedure Popup
( | Menu | : access Gtk_Menu_Record; |
Parent_Menu_Shell | : Gtk.Menu_Shell.Gtk_Menu_Shell := null; | |
Parent_Menu_Item | : Gtk.Menu_Item.Gtk_Menu_Item := null; | |
Func | : C_Gtk_Menu_Position_Func := null; | |
User_Data | : System.Address; | |
Button | : Guint := 1; | |
Activate_Time | : Guint32 := 0); |
procedure Reposition
( | Menu | : access Gtk_Menu_Record); |
procedure Set_Monitor
( | Menu | : access Gtk_Menu_Record; |
Monitor_Num | : Gint); |
function Get_Monitor
( | Menu | : access Gtk_Menu_Record) return Gint; |
procedure Set_Screen
( | Menu | : access Gtk_Menu_Record; |
Screen | : access Gdk.Screen.Gdk_Screen_Record'Class); |
procedure Set_Accel_Group
( | Menu | : access Gtk_Menu_Record; |
Accel | : Accel_Group.Gtk_Accel_Group); |
function Get_Accel_Group
( | Menu | : access Gtk_Menu_Record) return Accel_Group.Gtk_Accel_Group; |
procedure Set_Accel_Path
( | Menu | : access Gtk_Menu_Record; |
Accel_Path | : UTF8_String); |
function Get_Accel_Path
( | Menu | : access Gtk_Menu_Record) return String; |
procedure Attach_To_Widget
( | Menu | : access Gtk_Menu_Record; |
Attach_Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; | |
Detacher | : Gtk_Menu_Detach_Func); |
procedure Detach
( | Menu | : access Gtk_Menu_Record); |
function Get_Attach_Widget
( | Menu | : access Gtk_Menu_Record) return Gtk.Widget.Gtk_Widget; |
function Get_For_Attach_Widget
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class) return Gtk.Widget.Widget_List.Glist; |
This widget implements a drop-down menu.
This is basically a simple box that contains a series of Gtk_Menu_Item widgets, on which the user can click to perform actions.
Such a menu is usually part of a Gtk_Menu_Bar (at the top of the window), or activated by clicking on an item in another Gtk_Menu.
See Gtk.Option_Menu for another way of displaying menus.
All the menus in GtkAda can be "Tear off" menus, i.e you can detach them from their parent (either a menu bar or another menu) to keep them visible on the screen at all times).
It is worth noting that by default, the user of your application will be able to dynamically modify the shortcuts associated with each menu item.
For instance, selecting a menu item and pressing a key will assign this new shortcut to the item, possibly removing the shortcut from any other item it was associated with.
Note that pressing <backspace> will simply remove the shortcut.
This default behavior, somewhat unexpected, can be canceled.
There are two ways to control this behavior: you can lock a specific menu item by calling Gtk.Widget.Lock_Accelerators on it. But you can also lock all the menu items at once by calling Gtk.Accel_Group.Lock for all the accelerator groups that were used (the GUI builder gate generally creates a single one), as well as on the group returned by Gtk.Accel_Group.Get_Default, which is the one used for items that don't initially have a shortcut.
Binding from C File version 2.16.6
<testgtk>create_menu.adb</testgtk>