TQContextMenuEvent Class

Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# TQContextMenuEvent Class Reference

The TQContextMenuEvent class contains parameters that describe a context menu event. More...

`#include <tqevent.h>`

Inherits TQEvent.

List of all member functions.

## Public Members

- enum Reason { Mouse, Keyboard, Other }
- TQContextMenuEvent ( Reason reason, const TQPoint & pos, const TQPoint & globalPos, int state )
- TQContextMenuEvent ( Reason reason, const TQPoint & pos, int state )
- int x () const
- int y () const
- int globalX () const
- int globalY () const
- const TQPoint & pos () const
- const TQPoint & globalPos () const
- ButtonState state () const
- bool isAccepted () const
- bool isConsumed () const
- void consume ()
- void accept ()
- void ignore ()
- Reason reason () const

## Detailed Description

The TQContextMenuEvent class contains parameters that describe a context menu event.

Context menu events are sent to widgets when a user triggers a context menu. What triggers this is platform dependent. For example, on Windows, pressing the menu button or releasing the right mouse button will cause this event to be sent.

When this event occurs it is customary to show a TQPopupMenu with a context menu, if this is relevant to the context.

Context menu events contain a special accept flag that indicates whether the receiver accepted the event. If the event handler does not accept the event, then whatever triggered the event will be handled as a regular input event if possible.

See also TQPopupMenu and Event Classes.

## Member Type Documentation

### TQContextMenuEvent::Reason

This enum describes the reason the ContextMenuEvent was sent. The values are:

- `TQContextMenuEvent::Mouse` - The mouse caused the event to be sent. Normally this means the right mouse button was clicked, but this is platform specific.
- `TQContextMenuEvent::Keyboard` - The keyboard caused this event to be sent. On Windows this means the menu button was pressed.
- `TQContextMenuEvent::Other` - The event was sent by some other means (i.e. not by the mouse or keyboard).

## Member Function Documentation

### TQContextMenuEvent::TQContextMenuEvent ( Reason reason, const TQPoint & pos, const TQPoint & globalPos, int state )

Constructs a context menu event object with the accept parameter flag set to false.

The reason parameter must be TQContextMenuEvent::Mouse or TQContextMenuEvent::Keyboard.

The pos parameter specifies the mouse position relative to the receiving widget. globalPos is the mouse position in absolute coordinates. state is the ButtonState at the time of the event.

### TQContextMenuEvent::TQContextMenuEvent ( Reason reason, const TQPoint & pos, int state )

Constructs a context menu event object with the accept parameter flag set to false.

The reason parameter must be TQContextMenuEvent::Mouse or TQContextMenuEvent::Keyboard.

The pos parameter specifies the mouse position relative to the receiving widget. state is the ButtonState at the time of the event.

The globalPos() is initialized to TQCursor::pos(), which may not be appropriate. Use the other constructor to specify the global position explicitly.

### void TQContextMenuEvent::accept ()

Sets the accept flag of the context event object.

Setting the accept flag indicates that the receiver of this event has processed the event. Processing the event means you did something with it and it will be implicitly consumed.

The accept flag is not set by default.

See also ignore() and consume().

### void TQContextMenuEvent::consume ()

Sets the consume flag of the context event object.

Setting the consume flag indicates that the receiver of this event does not want the event to be propagated further (i.e. not sent to parent classes.)

The consumed flag is not set by default.

See also ignore() and accept().

### const TQPoint & TQContextMenuEvent::globalPos () const

Returns the global position of the mouse pointer at the time of the event.

See also x(), y(), and pos().

### int TQContextMenuEvent::globalX () const

Returns the global x-position of the mouse pointer at the time of the event.

See also globalY() and globalPos().

### int TQContextMenuEvent::globalY () const

Returns the global y-position of the mouse pointer at the time of the event.

See also globalX() and globalPos().

### void TQContextMenuEvent::ignore ()

Clears the accept flag of the context event object.

Clearing the accept flag indicates that the receiver of this event does not need to show a context menu. This will implicitly remove the consumed flag as well.

The accept flag is not set by default.

See also accept() and consume().

### bool TQContextMenuEvent::isAccepted () const

Returns true if the receiver has processed the event; otherwise returns false.

See also accept(), ignore(), and consume().

### bool TQContextMenuEvent::isConsumed () const

Returns true (which stops propagation of the event) if the receiver has blocked the event; otherwise returns false.

See also accept(), ignore(), and consume().

### const TQPoint & TQContextMenuEvent::pos () const

Returns the position of the mouse pointer relative to the widget that received the event.

See also x(), y(), and globalPos().

### Reason TQContextMenuEvent::reason () const

Returns the reason for this context event.

### ButtonState TQContextMenuEvent::state () const

Returns the button state (a combination of mouse buttons and keyboard modifiers), i.e. what buttons and keys were being pressed immediately before the event was generated.

The returned value is LeftButton, RightButton, MidButton, ShiftButton, ControlButton and AltButton OR'ed together.

### int TQContextMenuEvent::x () const

Returns the x-position of the mouse pointer, relative to the widget that received the event.

See also y() and pos().

### int TQContextMenuEvent::y () const

Returns the y-position of the mouse pointer, relative to the widget that received the event.

See also x() and pos().

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.