This class is used to process the events generated by the system.
Any number of form handlers can be attached to any form. The last
attached handler will get the event first. If any handling
method returns true
it means, that the process is
handled and does not need any further processing. The default
behaviour is to return false
.
To handle the events yourself, create a subclass and override the
virtual methods for this base class.
Synopsis
#include <PLEvt.h>
PFormHandler();There is only the default constructor.
PFormHandler& handleFor(const PForm* frm)Registers a handler for a form object.
PFormHandler& stopHandlingFor(const PForm* frm);De-registers the handler for the object. If frm is 0, de-registers the handler for all forms it is registered for.
virtual Boolean open();is called when the form is loaded and shown.
virtual Boolean closed();is called when the form is closed. It is, however not called when a form issues a PForm::returnTo().
virtual Boolean save();is called by the system when the form should save it's precious data. It's going to be closed real soon.
virtual Boolean command(PCmdEvt& cmdEvent);Is called, when the user selects a menu, button or checkbox control. See PCmdEvt for details.
virtual Boolean update(const Word& code);is called when the form should redraw itself.
code
is
the update code supplied by the system or the application (see
PForm::update)
virtual Boolean key(PKeyEvt& keyEvent);Keys and graffiti strokes generate this event. See PKeyEvent for details.
virtual Boolean nil();called for system generated nil ticks. see PApplication::PApplication(...)
virtual Boolean scroll(PScrollEvt& scrollEvent);Is called, when the user selects or moves a scrollbar resource. See PScrollEvt for details. Scrollbars can be attached to fields and tables directly (PField, PScrollbar) so there is no need to handle this for these resources.
virtual Boolean titleSelect();The user tapped on the title bar. (Beware of MenuHack. You can specify
applicationFirst
in the
PApplication constructor to handle this event first).
virtual Boolean defaultHandler(PFormEvt& formEvent);Any other events can be handled with this method. See PFormEvt for details.
virtual Boolean dispatch(EventPtr e, const PWin hwnd);This is called by the main event loops dispatcher function, and dispatches the events to the handling functions. There is no real need to override this, as
defautlHandler(PFormEvt&)
receives every non-handled
event.(Word) hwnd == your_own_frmId
, and
return false immediately if not.