diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2023-03-31 17:12:51 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2023-04-06 10:53:21 +0200 |
commit | c19f041f27c9a297ec20107acc89e9b1144ec070 (patch) | |
tree | d7baba72d771139ed27b93620a5b031ca876d8a9 /vcl | |
parent | a6cc4d851f1a061af71e03af4c886638d6a5f3b3 (diff) |
jsdialog: implemented mouse events for drawingarea
Change-Id: Ieab3d9fdbcee90ccd125e84f74c06cd1d6711a9f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149953
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150057
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/salvtables.hxx | 6 | ||||
-rw-r--r-- | vcl/jsdialog/executor.cxx | 26 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 18 |
3 files changed, 40 insertions, 10 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index bd462ad56ccd..cbb9fce51eee 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1341,6 +1341,12 @@ public: virtual void click(const Point& rPos) override; virtual void dblclick(const Point& rPos) override; + + virtual void mouse_up(const Point& rPos) override; + + virtual void mouse_down(const Point& rPos) override; + + virtual void mouse_move(const Point& rPos) override; }; class SalInstanceToolbar : public SalInstanceWidget, public virtual weld::Toolbar diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index cb8dfa4d455c..eb11af9b2884 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -192,7 +192,8 @@ bool ExecuteAction(const OUString& nWindowId, const OUString& rWidget, StringMap auto pArea = dynamic_cast<weld::DrawingArea*>(pWidget); if (pArea) { - if (sAction == "click" || sAction == "dblclick") + if (sAction == "click" || sAction == "dblclick" || sAction == "mousemove" + || sAction == "mousedown" || sAction == "mouseup") { OUString sClickData = rData["data"]; int nSeparatorPos = sClickData.indexOf(';'); @@ -205,23 +206,28 @@ bool ExecuteAction(const OUString& nWindowId, const OUString& rWidget, StringMap if (nClickPosX.empty() || nClickPosY.empty()) return true; - double posX = o3tl::toDouble(nClickPosX); - double posY = o3tl::toDouble(nClickPosY); + double fPosX = o3tl::toDouble(nClickPosX); + double fPosY = o3tl::toDouble(nClickPosY); OutputDevice& rRefDevice = pArea->get_ref_device(); // We send OutPutSize for the drawing area bitmap // get_size_request is not necessarily updated // therefore it may be incorrect. Size size = rRefDevice.GetOutputSizePixel(); - posX = posX * size.Width(); - posY = posY * size.Height(); + fPosX = fPosX * size.Width(); + fPosY = fPosY * size.Height(); + if (sAction == "click") - LOKTrigger::trigger_click(*pArea, Point(posX, posY)); - else - LOKTrigger::trigger_dblclick(*pArea, Point(posX, posY)); - return true; + LOKTrigger::trigger_click(*pArea, Point(fPosX, fPosY)); + else if (sAction == "dblclick") + LOKTrigger::trigger_dblclick(*pArea, Point(fPosX, fPosY)); + else if (sAction == "mouseup") + LOKTrigger::trigger_mouse_up(*pArea, Point(fPosX, fPosY)); + else if (sAction == "mousedown") + LOKTrigger::trigger_mouse_down(*pArea, Point(fPosX, fPosY)); + else if (sAction == "mousemove") + LOKTrigger::trigger_mouse_move(*pArea, Point(fPosX, fPosY)); } - LOKTrigger::trigger_click(*pArea, Point(10, 10)); return true; } else if (sAction == "keypress") diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 3e13d215f2cb..0b818bf2f5f4 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -6348,6 +6348,24 @@ void SalInstanceDrawingArea::dblclick(const Point& rPos) m_xDrawingArea->MouseButtonUp(aEvent); } +void SalInstanceDrawingArea::mouse_up(const Point& rPos) +{ + MouseEvent aEvent(rPos, 0, MouseEventModifiers::NONE, MOUSE_LEFT, 0); + m_xDrawingArea->MouseButtonUp(aEvent); +} + +void SalInstanceDrawingArea::mouse_down(const Point& rPos) +{ + MouseEvent aEvent(rPos, 0, MouseEventModifiers::NONE, MOUSE_LEFT, 0); + m_xDrawingArea->MouseButtonDown(aEvent); +} + +void SalInstanceDrawingArea::mouse_move(const Point& rPos) +{ + MouseEvent aEvent(rPos, 0, MouseEventModifiers::NONE, MOUSE_LEFT, 0); + m_xDrawingArea->MouseMove(aEvent); +} + IMPL_LINK(SalInstanceDrawingArea, PaintHdl, target_and_area, aPayload, void) { m_aDrawHdl.Call(aPayload); |