Gtk.MenuButton

const Gtk = imports.gi.Gtk;

let menu_button = new Gtk.MenuButton({
    align_widget: value,
    direction: value,
    menu_model: value,
    popup: value,
});
  

The Gtk.MenuButton widget is used to display a menu when clicked on. This menu can be provided either as a Gtk.Menu, or an abstract Gio.MenuModel.

The Gtk.MenuButton widget can hold any valid child widget. That is, it can hold almost any other standard Gtk.Widget. The most commonly used child is the provided Gtk.Arrow.

The positioning of the menu is determined by the Gtk.direction property of the menu button and the Gtk.halign or Gtk.valign properties of the menu. For example, when the direction is Gtk.ArrowType.down and the horizontal alignment is Gtk.Align.start, the menu will be positioned below the button, with the starting edge (depending on the text direction) of the menu aligned with the starting edge of the button. If there is not enough space below the button, the menu is popped up above the button instead. If the alignment would move part of the menu offscreen, it is 'pushed in'.

<informaltable> <tgroup cols="4"> <tbody> <row> <entry></entry> <entry>halign = start</entry> <entry>halign = center</entry> <entry>halign = end</entry> </row> <row> <entry>direction = down</entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="down-start.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="down-center.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="down-end.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> </row> <row> <entry>direction = up</entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="up-start.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="up-center.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="up-end.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> </row> </tbody> </tgroup> </informaltable> <informaltable> <tgroup cols="3"> <tbody> <row> <entry></entry> <entry>direction = left</entry> <entry>direction = right</entry> </row> <row> <entry>valign = start</entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="left-start.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="right-start.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> </row> <row> <entry>valign = center</entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="left-center.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="right-center.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> </row> <row> <entry>valign = end</entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="left-end.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> <entry> <inlinemediaobject> <imageobject><imagedata fileref="right-end.png" format="PNG"/></imageobject> </inlinemediaobject> </entry> </row> </tbody> </tgroup> </informaltable>

Hierarchy

  • GObject.Object
    • GObject.InitiallyUnowned
      • Gtk.Widget
        • Gtk.Container
          • Gtk.Bin
            • Gtk.Button
              • Gtk.ToggleButton
                • Gtk.MenuButton