Responder Class Referenceabstract

#include <Pt/Forms/Responder.h>

Object that handles input or forwards it. More...

Inherited by Widget.

Public Member Functions

virtual ~Responder ()
 Destructor.
 
bool mouseEvent (const MouseEvent &ev)
 Delivers ev along the mouse responder chain. More...
 
void touchEvent (const TouchEvent &ev)
 Delivers ev along the touch responder chain. More...
 
void scrollEvent (const ScrollEvent &ev)
 Delivers ev along the scroll responder chain.
 
void enterEvent (const EnterEvent &ev)
 Delivers ev along the enter responder chain.
 
void leaveEvent (const LeaveEvent &ev)
 Delivers ev along the leave responder chain.
 
void keyEvent (const KeyEvent &ev)
 Delivers ev along the key responder chain.
 

Protected Member Functions

 Responder ()
 Creates a responder.
 
virtual ResponderonNextResponder ()=0
 Returns the next responder, or 0 at the end of the chain.
 
virtual Gfx::PointF onToGlobal (const Gfx::PointF &pos) const =0
 Converts local position pos to global coordinates.
 
virtual Gfx::PointF onFromGlobal (const Gfx::PointF &pos) const =0
 Converts global position pos to local coordinates.
 
virtual bool onMouseEvent (const MouseEvent &ev)
 Handles a mouse event in local coordinates. More...
 
virtual bool onTouchEvent (const TouchEvent &ev)
 Handles a touch event in local coordinates. More...
 
virtual bool onScrollEvent (const ScrollEvent &ev)
 Handles a scroll event. More...
 
virtual bool onEnterEvent (const EnterEvent &ev)
 Handles pointer entry. More...
 
virtual bool onLeaveEvent (const LeaveEvent &ev)
 Handles pointer leave. More...
 
virtual bool onKeyEvent (const KeyEvent &ev)
 Handles a key event. More...
 
virtual bool onMousePress (const MouseEvent &ev)
 Handles a mouse press. The default returns false.
 
virtual bool onMouseRelease (const MouseEvent &ev)
 Handles a mouse release. The default returns false.
 
virtual bool onMouseMove (const MouseEvent &ev)
 Handles a mouse move. The default returns false.
 

Detailed Description

A Responder is the unit of input delivery. Widget is the usual responder. Handle an event by returning true; return false to continue to the next responder. Mouse and touch positions are converted to the current responder's local coordinates before the handler runs.

Applications derive visual content from Control, not from Responder. A custom responder must implement onNextResponder(), onToGlobal(), and onFromGlobal() and must not create a cycle in the chain.

Member Function Documentation

◆ mouseEvent()

bool mouseEvent ( const MouseEvent ev)

Converts the position to each responder's local coordinates. Returns true when a responder handles the event.

◆ touchEvent()

void touchEvent ( const TouchEvent ev)

Converts the position to each responder's local coordinates.

◆ onMouseEvent()

virtual bool onMouseEvent ( const MouseEvent ev)
protectedvirtual

Return true to stop the chain, false to continue.

Reimplemented in MenuItemBase, MenuBar, Menu, Window, Widget, SpinBox, Slider, ScrollLayout, ScrollBar, Screen, ListBoxItem, LineEdit, Form, Control, ComboBox, and Button.

◆ onTouchEvent()

virtual bool onTouchEvent ( const TouchEvent ev)
protectedvirtual

Return true to stop the chain, false to continue.

Reimplemented in Window, Widget, SpinBox, Slider, ScrollLayout, ScrollBar, Screen, ListBoxItem, LineEdit, Form, Control, ComboBox, Button, MenuItemBase, and MenuBar.

◆ onScrollEvent()

virtual bool onScrollEvent ( const ScrollEvent ev)
protectedvirtual

Return true to stop the chain, false to continue.

Reimplemented in Window, Widget, ScrollLayout, Screen, ListBoxItem, Form, Control, and Button.

◆ onEnterEvent()

virtual bool onEnterEvent ( const EnterEvent ev)
protectedvirtual

Return true to stop the chain, false to continue.

Reimplemented in MenuItemBase, Menu, Window, Widget, SpinBox, Slider, ScrollBar, ListBoxItem, LineEdit, Form, Control, ComboBox, and Button.

◆ onLeaveEvent()

virtual bool onLeaveEvent ( const LeaveEvent ev)
protectedvirtual

Return true to stop the chain, false to continue.

Reimplemented in MenuItemBase, Menu, Window, Widget, SpinBox, Slider, ScrollBar, ListBoxItem, LineEdit, Form, Control, ComboBox, and Button.

◆ onKeyEvent()

virtual bool onKeyEvent ( const KeyEvent ev)
protectedvirtual

Return true to stop the chain, false to continue.

Reimplemented in Window, Widget, SpinBox, Screen, LineEdit, Form, Control, and ComboBox.