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

#include <mouseevent.hpp>

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

Public Types

enum class  Button : std::uint8_t {
  Empty = 0 , Left , Middle , Right ,
  X1 , X2
}
enum class  Type : std::uint8_t {
  Moved = 0 , Pressed , Released , WheelMovedDown ,
  WheelMovedUp , WheelMovedRight , WheelMovedLeft , Clicked ,
  Entered , Exited , Dragged
}

Public Member Functions

MouseEvent::Button getButton () const
int getClickCount () const
MouseEvent::Type getType () const
int getX () const
int getY () const
 MouseEvent (Widget *source, Widget *distributor, bool isShiftPressed, bool isControlPressed, bool isAltPressed, bool isMetaPressed, MouseEvent::Type type, MouseEvent::Button button, int x, int y, int clickCount)
Public Member Functions inherited from fcn::InputEvent
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

MouseEvent::Button mButton
int mClickCount
MouseEvent::Type mType
int mX = 0
int mY = 0
Protected Attributes inherited from fcn::InputEvent
bool mAltPressed
bool mControlPressed
WidgetmDistributor
bool mIsConsumed
bool mMetaPressed
bool mShiftPressed
Protected Attributes inherited from fcn::Event
WidgetmSource {nullptr}

Friends

class Gui

Detailed Description

Represents a mouse event.

Definition at line 21 of file mouseevent.hpp.

Member Enumeration Documentation

◆ Button

enum class fcn::MouseEvent::Button : std::uint8_t
strong

Mouse button types.

Definition at line 45 of file mouseevent.hpp.

◆ Type

enum class fcn::MouseEvent::Type : std::uint8_t
strong

Mouse event types.

Definition at line 27 of file mouseevent.hpp.

Constructor & Destructor Documentation

◆ MouseEvent()

fcn::MouseEvent::MouseEvent ( Widget * source,
Widget * distributor,
bool isShiftPressed,
bool isControlPressed,
bool isAltPressed,
bool isMetaPressed,
MouseEvent::Type type,
MouseEvent::Button button,
int x,
int y,
int clickCount )

Constructor.

Parameters
sourceThe widget the event concerns.
distributorThe distributor of the mouse 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.
typeThe type of the mouse event.
buttonThe button of the mouse event.
xThe x coordinate of the event relative to the source widget.
yThe y coordinate of the event relative the source widget.
clickCountThe number of clicks generated with the same button. It's set to zero if another button is used.

Definition at line 11 of file mouseevent.cpp.

References fcn::InputEvent::InputEvent(), fcn::InputEvent::isAltPressed(), fcn::InputEvent::isControlPressed(), fcn::InputEvent::isMetaPressed(), fcn::InputEvent::isShiftPressed(), mButton, mClickCount, mType, mX, and mY.

Member Function Documentation

◆ getButton()

◆ getClickCount()

int fcn::MouseEvent::getClickCount ( ) const

Gets the number of clicks generated with the same button.

It's set to zero if another button is used.

Returns
The number of clicks generated with the same button.

Definition at line 47 of file mouseevent.cpp.

References mClickCount.

◆ getType()

MouseEvent::Type fcn::MouseEvent::getType ( ) const

Gets the type of the event.

Returns
The type of the event.

Definition at line 52 of file mouseevent.cpp.

References mType.

Referenced by fcn::Gui::distributeMouseEvent().

◆ getX()

int fcn::MouseEvent::getX ( ) const

Gets the x coordinate of the mouse event.

The coordinate relative to widget the mouse listener receiving the events have registered to.

Returns
The x coordinate of the mouse event.
See also
Widget::addMouseListener, Widget::removeMouseListener

Definition at line 37 of file mouseevent.cpp.

References mX.

Referenced by fcn::ScrollArea::mouseDragged(), fcn::Slider::mouseDragged(), fcn::Window::mouseDragged(), fcn::DropDown::mousePressed(), fcn::ScrollArea::mousePressed(), fcn::Slider::mousePressed(), fcn::TabbedArea::mousePressed(), fcn::TextBox::mousePressed(), fcn::TextField::mousePressed(), fcn::Window::mousePressed(), and fcn::DropDown::mouseReleased().

◆ getY()

int fcn::MouseEvent::getY ( ) const

Gets the y coordinate of the mouse event.

The coordinate relative to widget the mouse listener receiving the events have registered to.

Returns
The y coordinate of the mouse event.
See also
Widget::addMouseListener, Widget::removeMouseListener

Definition at line 42 of file mouseevent.cpp.

References mY.

Referenced by fcn::ScrollArea::mouseDragged(), fcn::Slider::mouseDragged(), fcn::Window::mouseDragged(), fcn::DropDown::mousePressed(), fcn::ListBox::mousePressed(), fcn::ScrollArea::mousePressed(), fcn::Slider::mousePressed(), fcn::TabbedArea::mousePressed(), fcn::TextBox::mousePressed(), fcn::TextField::mousePressed(), fcn::Window::mousePressed(), and fcn::DropDown::mouseReleased().

◆ 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 x och y coordinates for the coordinates to be relative to widget the mouse listener receiving the events have registered to.

Definition at line 161 of file mouseevent.hpp.

References Gui.

Referenced by Gui.

Member Data Documentation

◆ mButton

MouseEvent::Button fcn::MouseEvent::mButton
protected

Holds the button of the mouse event.

Definition at line 135 of file mouseevent.hpp.

Referenced by getButton(), and MouseEvent().

◆ mClickCount

int fcn::MouseEvent::mClickCount
protected

The number of clicks generated with the same button.

It's set to zero if another button is used.

Definition at line 151 of file mouseevent.hpp.

Referenced by getClickCount(), and MouseEvent().

◆ mType

MouseEvent::Type fcn::MouseEvent::mType
protected

Holds the type of the mouse event.

Definition at line 130 of file mouseevent.hpp.

Referenced by getType(), and MouseEvent().

◆ mX

int fcn::MouseEvent::mX = 0
protected

Holds the x-coordinate of the mouse event.

Definition at line 140 of file mouseevent.hpp.

Referenced by fcn::Gui::distributeMouseEvent(), getX(), and MouseEvent().

◆ mY

int fcn::MouseEvent::mY = 0
protected

Holds the y-coordinate of the mouse event.

Definition at line 145 of file mouseevent.hpp.

Referenced by fcn::Gui::distributeMouseEvent(), getY(), and MouseEvent().


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