FifeGUI 0.2.0
A C++ GUI library designed for games.
fcn::InputEvent Class Reference

#include <inputevent.hpp>

Inheritance diagram for fcn::InputEvent:
fcn::Event fcn::KeyEvent fcn::MouseEvent

Public Member Functions

void consume ()
WidgetgetDistributor () const
 InputEvent (Widget *source, Widget *distributor, bool isShiftPressed, bool isControlPressed, bool isAltPressed, bool isMetaPressed)
bool isAltPressed () const
bool isConsumed () const
bool isControlPressed () const
bool isMetaPressed () const
bool isShiftPressed () const
Public Member Functions inherited from fcn::Event
 Event (Widget *source)
WidgetgetSource () const

Protected Attributes

bool mAltPressed
bool mControlPressed
WidgetmDistributor
bool mIsConsumed
bool mMetaPressed
bool mShiftPressed
Protected Attributes inherited from fcn::Event
WidgetmSource {nullptr}

Friends

class Gui

Detailed Description

Base class for all input-related events (keyboard, mouse).

Definition at line 18 of file inputevent.hpp.

Constructor & Destructor Documentation

◆ InputEvent()

fcn::InputEvent::InputEvent ( Widget * source,
Widget * distributor,
bool isShiftPressed,
bool isControlPressed,
bool isAltPressed,
bool isMetaPressed )

Constructor.

Parameters
sourceThe widget the event concerns.
distributorThe distributor of the event.
isShiftPressedTrue if shift is pressed, false otherwise.
isControlPressedTrue if control is pressed, false otherwise.
isAltPressedTrue if alt is pressed, false otherwise.
isMetaPressedTrue if meta is pressed, false otherwise.

Definition at line 11 of file inputevent.cpp.

References fcn::Event::Event(), isAltPressed(), isControlPressed(), isMetaPressed(), isShiftPressed(), mAltPressed, mControlPressed, mDistributor, mIsConsumed, mMetaPressed, and mShiftPressed.

Referenced by fcn::KeyEvent::KeyEvent(), and fcn::MouseEvent::MouseEvent().

Member Function Documentation

◆ consume()

void fcn::InputEvent::consume ( )

Marks the event as consumed.

Input event listeners may discard consumed input or act on consumed input. An example of a widget that discards consumed input is the ScrollArea widget that discards consumed mouse wheel events so the ScrollArea will not scroll if for instance a Slider's value inside the ScrollArea was changed with the mouse wheel.

See also
isConsumed

Definition at line 48 of file inputevent.cpp.

References mIsConsumed.

Referenced by fcn::Button::keyPressed(), fcn::CheckBox::keyPressed(), fcn::DropDown::keyPressed(), fcn::ListBox::keyPressed(), fcn::PasswordField::keyPressed(), fcn::Slider::keyPressed(), fcn::TabbedArea::keyPressed(), fcn::TextBox::keyPressed(), fcn::TextField::keyPressed(), fcn::Button::keyReleased(), fcn::CheckBox::keyReleased(), fcn::ToggleButton::keyReleased(), fcn::CheckBox::mouseClicked(), fcn::Button::mouseDragged(), fcn::DropDown::mouseDragged(), fcn::ListBox::mouseDragged(), fcn::ScrollArea::mouseDragged(), fcn::Slider::mouseDragged(), fcn::TextBox::mouseDragged(), fcn::TextField::mouseDragged(), fcn::Window::mouseDragged(), fcn::Button::mousePressed(), fcn::CheckBox::mousePressed(), fcn::TextBox::mousePressed(), fcn::Button::mouseReleased(), fcn::CheckBox::mouseReleased(), fcn::ScrollArea::mouseReleased(), fcn::ToggleButton::mouseReleased(), fcn::DropDown::mouseWheelMovedDown(), fcn::ListBox::mouseWheelMovedDown(), fcn::ScrollArea::mouseWheelMovedDown(), fcn::Slider::mouseWheelMovedDown(), fcn::ScrollArea::mouseWheelMovedLeft(), fcn::Slider::mouseWheelMovedLeft(), fcn::ScrollArea::mouseWheelMovedRight(), fcn::Slider::mouseWheelMovedRight(), fcn::DropDown::mouseWheelMovedUp(), fcn::ListBox::mouseWheelMovedUp(), fcn::ScrollArea::mouseWheelMovedUp(), and fcn::Slider::mouseWheelMovedUp().

◆ getDistributor()

Widget * fcn::InputEvent::getDistributor ( ) const

Gets the distributor of the event.

The function is used to tell which widget actually distributed the event. As input events bubbles up, the source of the event may not be the same as the distributor of the event.

Definition at line 58 of file inputevent.cpp.

References mDistributor.

◆ isAltPressed()

bool fcn::InputEvent::isAltPressed ( ) const

Checks if alt is pressed.

Returns
True if alt was pressed at the same time as the key, false otherwise.

Definition at line 38 of file inputevent.cpp.

References mAltPressed.

Referenced by InputEvent(), fcn::KeyEvent::KeyEvent(), and fcn::MouseEvent::MouseEvent().

◆ isConsumed()

bool fcn::InputEvent::isConsumed ( ) const

◆ isControlPressed()

bool fcn::InputEvent::isControlPressed ( ) const

Checks if control is pressed.

Returns
True if control was pressed at the same time as the key, false otherwise.

Definition at line 33 of file inputevent.cpp.

References mControlPressed.

Referenced by InputEvent(), fcn::KeyEvent::KeyEvent(), and fcn::MouseEvent::MouseEvent().

◆ isMetaPressed()

bool fcn::InputEvent::isMetaPressed ( ) const

Checks whether meta is pressed.

Returns
True if meta was pressed at the same time as the key, false otherwise.

Definition at line 43 of file inputevent.cpp.

References mMetaPressed.

Referenced by InputEvent(), fcn::KeyEvent::KeyEvent(), and fcn::MouseEvent::MouseEvent().

◆ isShiftPressed()

bool fcn::InputEvent::isShiftPressed ( ) const

Checks if shift is pressed.

Returns
True if shift was pressed at the same time as the key, false otherwise.

Definition at line 28 of file inputevent.cpp.

References mShiftPressed.

Referenced by InputEvent(), fcn::KeyEvent::KeyEvent(), and fcn::MouseEvent::MouseEvent().

◆ Gui

friend class Gui
friend

Gui is a friend of this class in order to be able to manipulate the protected member variables of this class and at the same time keep the MouseEvent class as const as possible.

Gui needs to update the distributer of this class whenever the distributer changes as events bubble up.

Definition at line 139 of file inputevent.hpp.

References Gui.

Referenced by Gui.

Member Data Documentation

◆ mAltPressed

bool fcn::InputEvent::mAltPressed
protected

True if alt is pressed, false otherwise.

Definition at line 114 of file inputevent.hpp.

Referenced by InputEvent(), and isAltPressed().

◆ mControlPressed

bool fcn::InputEvent::mControlPressed
protected

True if control is pressed, false otherwise.

Definition at line 109 of file inputevent.hpp.

Referenced by InputEvent(), and isControlPressed().

◆ mDistributor

Widget* fcn::InputEvent::mDistributor
protected

Holds the distributor of the event.

Definition at line 130 of file inputevent.hpp.

Referenced by fcn::Gui::distributeKeyEvent(), fcn::Gui::distributeMouseEvent(), getDistributor(), and InputEvent().

◆ mIsConsumed

bool fcn::InputEvent::mIsConsumed
protected

True if the input event is consumed, false otherwise.

Definition at line 125 of file inputevent.hpp.

Referenced by consume(), InputEvent(), and isConsumed().

◆ mMetaPressed

bool fcn::InputEvent::mMetaPressed
protected

True if meta is pressed, false otherwise.

Definition at line 119 of file inputevent.hpp.

Referenced by InputEvent(), and isMetaPressed().

◆ mShiftPressed

bool fcn::InputEvent::mShiftPressed
protected

True if shift is pressed, false otherwise.

Definition at line 104 of file inputevent.hpp.

Referenced by InputEvent(), and isShiftPressed().


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