Popup Menus
Prev | Chapter 10. Menus and Toolbars | Next

## Popup Menus

TODO: Update for UIManager API. Menus are normally just added to a window, but they can also be displayed temporarily as the result of a mouse button click. For instance, a context menu might be diplayed when the user clicks their right mouse button. You can use `Gtk::Menu`'s `popup()` method, but you need to provide a button identifier and the time of activation. This information is provided by the `button_press_event` signal, which you will need to handle anyway. For instance:

    bool ExampleWindow::on_button_press_event(GdkEventButton* event)
    {
      if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) )
      {
        m_Menu_Popup.popup(event->button, event->time);
        return true; //It has been handled.
      }
      else
        return false;
    }

Prev | Up | Next
UIManager | Home | Examples