mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
LibWeb: Add a DOM Event class (instead of events being simple strings)
This patch adds the Event base class, along with a MouseEvent subclass. We now dispatch MouseEvent objects for mousedown, mouseup and mousemove and these objects have the .offsetX and .offsetY properties. Both of those properties are hard-coded at the moment. This will be fixed in the next patch. :^)
This commit is contained in:
parent
b196665131
commit
4dde36844b
15 changed files with 311 additions and 10 deletions
36
Libraries/LibWeb/DOM/MouseEvent.h
Normal file
36
Libraries/LibWeb/DOM/MouseEvent.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
class MouseEvent final : public Event {
|
||||
public:
|
||||
using WrapperType = Bindings::MouseEventWrapper;
|
||||
|
||||
static NonnullRefPtr<MouseEvent> create(String event_name, i32 offset_x, i32 offset_y)
|
||||
{
|
||||
return adopt(*new MouseEvent(move(event_name), offset_x, offset_y));
|
||||
}
|
||||
|
||||
virtual ~MouseEvent() override {}
|
||||
|
||||
i32 offset_x() const { return m_offset_x; }
|
||||
i32 offset_y() const { return m_offset_y; }
|
||||
|
||||
protected:
|
||||
MouseEvent(String event_name, i32 offset_x, i32 offset_y)
|
||||
: Event(move(event_name))
|
||||
, m_offset_x(offset_x)
|
||||
, m_offset_y(offset_y)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool is_mouse_event() const override { return true; }
|
||||
|
||||
i32 m_offset_x { 0 };
|
||||
i32 m_offset_y { 0 };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue