# wxEventBlocker Class Reference
[Events]

`#include </home/work/projects/wx/2.9/wx/interface/wx/event.h>`

Inheritance diagram for wxEventBlocker:
[legend]

## Detailed Description

This class is a special event handler which allows to discard any event (or a set of event types) directed to a specific window.

Example:

        void MyWindow::DoSomething()
        {
            {
                // block all events directed to this window while
                // we do the 1000 FunctionWhichSendsEvents() calls
                wxEventBlocker blocker(this);

                for ( int i = 0; i  1000; i++ )
                    FunctionWhichSendsEvents(i);

            } // ~wxEventBlocker called, old event handler is restored

            // the event generated by this call will be processed:
            FunctionWhichSendsEvents(0)
        }

##

Library: wxCore
Category: Events

See also:
  How Events are Processed, wxEvtHandler

## Public Member Functions

| wxEventBlocker (wxWindow *win, wxEventType type=-1)
| Constructs the blocker for the given window and for the given event type.
virtual | ~wxEventBlocker ()
| Destructor.
void | Block (wxEventType eventType)
| Adds to the list of event types which should be blocked the given eventType.

List of all members.

## Constructor & Destructor Documentation

wxEventBlocker::wxEventBlocker | ( | wxWindow * | win,
|  | wxEventType | type = `-1` |
| ) |  |  |

Constructs the blocker for the given window and for the given event type.

If type is `wxEVT_ANY`, then all events for that window are blocked. You can call Block() after creation to add other event types to the list of events to block.

Note that the win window must remain alive until the wxEventBlocker object destruction.

virtual wxEventBlocker::~wxEventBlocker | ( |  | ) | `[virtual]`

Destructor.

The blocker will remove itself from the chain of event handlers for the window provided in the constructor, thus restoring normal processing of events.

## Member Function Documentation

void wxEventBlocker::Block | ( | wxEventType | eventType | ) |

Adds to the list of event types which should be blocked the given eventType.

|  | [ top ]