| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KPopupMenu Class Reference

KPopupMenu is a class for menus with standard title items and keyboard accessibility for popups with many options and/or varying options. A menu with title items. More...

`#include <kpopupmenu.h>`

Inheritance diagram for KPopupMenu:

[legend]
Collaboration diagram for KPopupMenu:

[legend]
List of all members.

## Public Member Functions
| KPopupMenu (QWidget *parent=0, const char *name=0)
| Constructs a KPopupMenu.
| ~KPopupMenu ()
| Destructs the object.
int | insertTitle (const QString &text, int id=-1, int index=-1)
| Inserts a title item with no icon.
int | insertTitle (const QPixmap &icon, const QString &text, int id=-1, int index=-1)
| Inserts a title item with the given icon and title.
void | changeTitle (int id, const QString &text)
| Changes the title of the item at the specified id.
void | changeTitle (int id, const QPixmap &icon, const QString &text)
| Changes the title and icon of the title item at the specified id.
QString | title (int id=-1) const
| Returns the title of the title item at the specified id.
QPixmap | titlePixmap (int id) const
| Returns the icon of the title item at the specified id.
void | setKeyboardShortcutsEnabled (bool enable)
| Enables keyboard navigation by searching for the entered key sequence.
void | setKeyboardShortcutsExecute (bool enable)
| Enables execution of the menu item once it is uniquely specified.
| KPopupMenu (const QString &title, QWidget *parent=0, const char *name=0)
| Obsolete method provided for backwards compatibility only.
void | setTitle (const QString &title)
| Obsolete method provided for backwards compatibility only.
## Protected Slots
QString | underlineText (const QString &text, uint length)
| Since: 3.1
void | resetKeyboardVars (bool noMatches=false)
| Since: 3.1
## Protected Member Functions
virtual void | closeEvent (QCloseEvent *)
| This is re-implemented for keyboard navigation.
virtual void | keyPressEvent (QKeyEvent *e)
virtual void | virtual_hook (int id, void *data)

## Detailed Description

KPopupMenu is a class for menus with standard title items and keyboard accessibility for popups with many options and/or varying options. A menu with title items.

It acts identically to QPopupMenu, with the addition of insertTitle(), changeTitle(), setKeyboardShortcutsEnabled() and setKeyboardShortcutsExecute() methods.

The titles support a text string, an icon, plus user defined gradients, colors, and background pixmaps.

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

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

  Hamish Rodda <meddie@yoyo.its.monash.edu.au>

Definition at line 116 of file kpopupmenu.h.

## Constructor & Destructor Documentation

KPopupMenu::KPopupMenu | ( | QWidget * | parent = 0,
|  | const char * | name = 0
| ) |

| Constructs a KPopupMenu. Definition at line 223 of file kpopupmenu.cpp. References KStdAccel::name(), and resetKeyboardVars().

KPopupMenu::~KPopupMenu | ( |  | ) |

| Destructs the object. Definition at line 231 of file kpopupmenu.cpp.

KPopupMenu::KPopupMenu | ( | const QString & | title,
|  | QWidget * | parent = 0,
|  | const char * | name = 0
| ) |

| Obsolete method provided for backwards compatibility only. Use the normal constructor and insertTitle instead. Definition at line 515 of file kpopupmenu.cpp. References KStdAccel::name(), and setTitle().

## Member Function Documentation

int KPopupMenu::insertTitle | ( | const QString & | text,
|  | int | id = -1,
|  | int | index = -1
| ) |

| Inserts a title item with no icon. Definition at line 236 of file kpopupmenu.cpp. References QPopupMenu::insertItem(), QPopupMenu::setItemEnabled(), and KPopupTitle::setTitle(). Referenced by KSystemTray::KSystemTray().

int KPopupMenu::insertTitle | ( | const QPixmap & | icon,
|  | const QString & | text,
|  | int | id = -1,
|  | int | index = -1
| ) |

| Inserts a title item with the given icon and title. Definition at line 245 of file kpopupmenu.cpp. References QPopupMenu::insertItem(), QPopupMenu::setItemEnabled(), and KPopupTitle::setTitle().

void KPopupMenu::changeTitle | ( | int | id,
|  | const QString & | text
| ) |

| Changes the title of the item at the specified id. If a icon was previously set it is cleared. Definition at line 255 of file kpopupmenu.cpp.

void KPopupMenu::changeTitle | ( | int | id,
|  | const QPixmap & | icon,
|  | const QString & | text
| ) |

| Changes the title and icon of the title item at the specified id. Definition at line 268 of file kpopupmenu.cpp.

QString KPopupMenu::title | ( | int | id = -1 | ) | const

| Returns the title of the title item at the specified id. The default id of -1 is for backwards compatibility only, you should always specify the id. Definition at line 281 of file kpopupmenu.cpp.

QPixmap KPopupMenu::titlePixmap | ( | int | id | ) | const

| Returns the icon of the title item at the specified id. Definition at line 297 of file kpopupmenu.cpp.

void KPopupMenu::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. WARNING: 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. Since: 3.1 Definition at line 501 of file kpopupmenu.cpp. Referenced by KPanelMenu::init().

void KPopupMenu::setKeyboardShortcutsExecute | ( | bool | enable | ) |

| Enables execution of the menu item once it is uniquely specified. Defaults to off. Since: 3.1 Definition at line 506 of file kpopupmenu.cpp.

void KPopupMenu::setTitle | ( | const QString & | title | ) |

| Obsolete method provided for backwards compatibility only. Use insertTitle and changeTitle instead. Definition at line 523 of file kpopupmenu.cpp. References QPopupMenu::insertItem(), and KPopupTitle::setTitle(). Referenced by KPopupMenu().

void KPopupMenu::closeEvent | ( | QCloseEvent * | e | ) | `[protected, virtual]`

| This is re-implemented for keyboard navigation. Definition at line 315 of file kpopupmenu.cpp. References resetKeyboardVars().

QString KPopupMenu::underlineText | ( | const QString & | text,
|  | uint | length
| ) | `[protected, slot]`

| Since: 3.1 Definition at line 476 of file kpopupmenu.cpp. References QString::insert().

void KPopupMenu::resetKeyboardVars | ( | bool | noMatches = false | ) | `[protected, slot]`

| Since: 3.1 Definition at line 486 of file kpopupmenu.cpp. References QPopupMenu::changeItem(), and QPopupMenu::idAt(). Referenced by closeEvent(), and KPopupMenu().

The documentation for this class was generated from the following files:

- kpopupmenu.h
- kpopupmenu.cpp

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:03:51 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001