• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

KMenu Class Reference

A menu with keyboard searching. More...

#include <kmenu.h>

Inheritance diagram for KMenu:
QMenu

List of all members.

Signals

void aboutToShowContextMenu (KMenu *menu, QAction *menuAction, QMenu *ctxMenu)

Public Member Functions

QAction * addTitle (const QIcon &icon, const QString &text, QAction *before=0L)
QAction * addTitle (const QString &text, QAction *before=0L)
const QMenu * contextMenu () const
QMenu * contextMenu ()
void hideContextMenu ()
Qt::KeyboardModifiers keyboardModifiers () const
 KMenu (const QString &title, QWidget *parent=0L)
 KMenu (QWidget *parent=0L)
Qt::MouseButtons mouseButtons () const
void setKeyboardShortcutsEnabled (bool enable)
void setKeyboardShortcutsExecute (bool enable)
 ~KMenu ()

Static Public Member Functions

static KMenu * contextMenuFocus ()
static QAction * contextMenuFocusAction ()

Protected Member Functions

virtual void closeEvent (QCloseEvent *)
virtual void contextMenuEvent (QContextMenuEvent *e)
virtual bool focusNextPrevChild (bool next)
virtual void hideEvent (QHideEvent *)
virtual void keyPressEvent (QKeyEvent *e)
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)

Detailed Description

A menu with keyboard searching.

KMenu is a class for menus with keyboard accessibility for popups with many options and/or varying options. It acts identically to QMenu, with the addition of setKeyboardShortcutsEnabled() and setKeyboardShortcutsExecute() methods.

The keyboard search algorithm is incremental with additional underlining for user feedback.

Author:
Daniel M. Duley <mosfet@kde.org>
Hamish Rodda <rodda@kde.org>

Definition at line 42 of file kmenu.h.


Constructor & Destructor Documentation

KMenu::KMenu ( QWidget *  parent = 0L  )  [explicit]

Constructs a KMenu.

Definition at line 160 of file kmenu.cpp.

KMenu::KMenu ( const QString &  title,
QWidget *  parent = 0L 
) [explicit]

Constructs a KMenu.

Parameters:
title The text displayed in a parent menu when it is inserted into another menu as a submenu.
parent the parent QWidget object

Definition at line 167 of file kmenu.cpp.

KMenu::~KMenu (  ) 

Destructs the object.

Definition at line 174 of file kmenu.cpp.


Member Function Documentation

void KMenu::aboutToShowContextMenu ( KMenu *  menu,
QAction *  menuAction,
QMenu *  ctxMenu 
) [signal]

connect to this signal to be notified when a context menu is about to be shown

Parameters:
menu The menu that the context menu is about to be shown for
menuAction The action that the context menu is currently on
ctxMenu The context menu itself
QAction * KMenu::addTitle ( const QIcon &  icon,
const QString &  text,
QAction *  before = 0L 
)

Inserts a title item with the given icon and title.

Definition at line 184 of file kmenu.cpp.

QAction * KMenu::addTitle ( const QString &  text,
QAction *  before = 0L 
)

Inserts a title item with no icon.

Definition at line 179 of file kmenu.cpp.

void KMenu::closeEvent ( QCloseEvent *  e  )  [protected, virtual]

This is re-implemented for keyboard navigation.

Definition at line 208 of file kmenu.cpp.

const QMenu * KMenu::contextMenu (  )  const

Returns the context menu associated with this menu.

Definition at line 472 of file kmenu.cpp.

QMenu * KMenu::contextMenu (  ) 

Returns the context menu associated with this menu The data property of all actions inserted into the context menu is modified all the time to point to the action and menu it has been shown for.

Definition at line 461 of file kmenu.cpp.

void KMenu::contextMenuEvent ( QContextMenuEvent *  e  )  [protected, virtual]

Definition at line 545 of file kmenu.cpp.

KMenu * KMenu::contextMenuFocus (  )  [static]

Returns the KMenu associated with the current context menu.

Definition at line 525 of file kmenu.cpp.

QAction * KMenu::contextMenuFocusAction (  )  [static]

returns the QAction associated with the current context menu

Definition at line 530 of file kmenu.cpp.

bool KMenu::focusNextPrevChild ( bool  next  )  [protected, virtual]

Definition at line 380 of file kmenu.cpp.

void KMenu::hideContextMenu (  ) 

Hides the context menu if shown.

Definition at line 477 of file kmenu.cpp.

void KMenu::hideEvent ( QHideEvent *  e  )  [protected, virtual]

Definition at line 565 of file kmenu.cpp.

Qt::KeyboardModifiers KMenu::keyboardModifiers (  )  const

Return the state of the keyboard modifiers when the last menuitem was activated.

Definition at line 220 of file kmenu.cpp.

void KMenu::keyPressEvent ( QKeyEvent *  e  )  [protected, virtual]

Definition at line 225 of file kmenu.cpp.

Qt::MouseButtons KMenu::mouseButtons (  )  const

Return the state of the mouse buttons when the last menuitem was activated.

Definition at line 215 of file kmenu.cpp.

void KMenu::mousePressEvent ( QMouseEvent *  e  )  [protected, virtual]

End keyboard navigation.

RMB menus on menus

Definition at line 428 of file kmenu.cpp.

void KMenu::mouseReleaseEvent ( QMouseEvent *  e  )  [protected, virtual]

Definition at line 442 of file kmenu.cpp.

void KMenu::setKeyboardShortcutsEnabled ( bool  enable  ) 

Enables keyboard navigation by searching for the entered key sequence.

Also underlines the currently selected item, providing feedback on the search.

Defaults to off.

Warning:
calls to text() of currently keyboard-selected items will contain additional ampersand characters.
though pre-existing keyboard shortcuts will not interfere with the operation of this feature, they may be confusing to the user as the existing shortcuts will not work. In addition, where text already contains ampersands, the underline produced is likely to confuse the user (as this feature uses underlining of text to indicate the current key selection sequence).

Definition at line 411 of file kmenu.cpp.

void KMenu::setKeyboardShortcutsExecute ( bool  enable  ) 

Enables execution of the menu item once it is uniquely specified.

Defaults to off.

Definition at line 416 of file kmenu.cpp.


The documentation for this class was generated from the following files:
  • kmenu.h
  • kmenu.cpp

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal