libyui  3.4.2
YSimpleEventHandler Class Reference

Simple event handler suitable for most UIs. More...

#include <YSimpleEventHandler.h>

Public Member Functions

 YSimpleEventHandler ()
 Constructor.
 
virtual ~YSimpleEventHandler ()
 Destructor. More...
 
void sendEvent (YEvent *event_disown)
 Widget event handlers call this when an event occured that should be the answer to a UserInput() / PollInput() (etc.) call. More...
 
bool eventPendingFor (YWidget *widget) const
 Returns 'true' if there is any event pending for the specified widget.
 
YEventpendingEvent () const
 Returns the last event that isn't processed yet or 0 if there is none. More...
 
YEventconsumePendingEvent ()
 Consumes the pending event. More...
 
void deletePendingEventsFor (YWidget *widget)
 Delete any pending events for the specified widget. More...
 
void clear ()
 Clears any pending event (deletes the corresponding object).
 
void blockEvents (bool block=true)
 Block (or unblock) events. More...
 
void unblockEvents ()
 Unblock events previously blocked. More...
 
bool eventsBlocked () const
 Returns 'true' if events are currently blocked.
 
void deleteEvent (YEvent *event)
 Delete an event. More...
 

Protected Attributes

YEvent_pendingEvent
 
bool _eventsBlocked
 

Detailed Description

Simple event handler suitable for most UIs.

This event handler keeps track of one single event that gets overwritten when a new one arrives.

Definition at line 39 of file YSimpleEventHandler.h.

Constructor & Destructor Documentation

◆ ~YSimpleEventHandler()

YSimpleEventHandler::~YSimpleEventHandler ( )
virtual

Destructor.

If there is a pending event, it is deleted here.

Definition at line 45 of file YSimpleEventHandler.cc.

Member Function Documentation

◆ blockEvents()

void YSimpleEventHandler::blockEvents ( bool  block = true)

Block (or unblock) events.

If events are blocked, any event sent with sendEvent() from now on is ignored (and will get lost) until events are unblocked again.

Definition at line 146 of file YSimpleEventHandler.cc.

◆ consumePendingEvent()

YEvent * YSimpleEventHandler::consumePendingEvent ( )

Consumes the pending event.

Sets the internal pending event to 0. Does NOT delete the internal consuming event.

The caller assumes ownership of the object this pending event points to. In particular, he has to take care to delete that object when he is done processing it.

Returns the pending event or 0 if there is none.

Definition at line 63 of file YSimpleEventHandler.cc.

◆ deleteEvent()

void YSimpleEventHandler::deleteEvent ( YEvent event)

Delete an event.

Don't call this from the outside; this is public only because of limitations of C++ .

Definition at line 157 of file YSimpleEventHandler.cc.

◆ deletePendingEventsFor()

void YSimpleEventHandler::deletePendingEventsFor ( YWidget widget)

Delete any pending events for the specified widget.

This is useful mostly if the widget is about to be destroyed.

Definition at line 131 of file YSimpleEventHandler.cc.

◆ pendingEvent()

YEvent* YSimpleEventHandler::pendingEvent ( ) const
inline

Returns the last event that isn't processed yet or 0 if there is none.

This event handler keeps track of only one single (the last one) event.

Definition at line 80 of file YSimpleEventHandler.h.

◆ sendEvent()

void YSimpleEventHandler::sendEvent ( YEvent event_disown)

Widget event handlers call this when an event occured that should be the answer to a UserInput() / PollInput() (etc.) call.

The UI assumes ownership of the event object that 'event' points to, so the event MUST be created with new(). The UI is to take care to delete the event after it has been processed.

If events are blocked (see blockEvents() ), the event sent with this function will be ignored (but safely deleted - no memory leak).

It is an error to pass 0 for 'event'.

This simple event handler keeps track of only the latest user event. If there is more than one, older events are automatically discarded. Since Events are created on the heap with the "new" operator, discarded events need to be deleted.

Events that are not discarded are deleted later (after they are processed) by the generic UI.

Definition at line 76 of file YSimpleEventHandler.cc.

◆ unblockEvents()

void YSimpleEventHandler::unblockEvents ( )
inline

Unblock events previously blocked.

This is just an alias for blockEvents( false) for better readability.

Definition at line 116 of file YSimpleEventHandler.h.


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