5 #include <ApplicationServices/ApplicationServices.h>
8 #include <QGuiApplication>
11 #include <QGraphicsSceneMouseEvent>
12 #include <QMouseEvent>
16 #include <score_lib_base_export.h>
19 inline void setCursorPos(QPointF pos) noexcept
21 #if defined(__APPLE__)
27 = CGEventCreateMouseEvent(
nullptr, kCGEventMouseMoved, ppos, kCGMouseButtonLeft);
28 CGEventPost(kCGHIDEventTap, e);
31 QCursor::setPos(pos.toPoint());
34 inline void moveCursorPos(QPointF pos) noexcept
36 #if defined(__APPLE__)
50 = CGEventCreateMouseEvent(
nullptr, kCGEventMouseMoved, ppos, kCGMouseButtonLeft);
51 CGEventPost(kCGHIDEventTap, e);
54 QCursor::setPos(pos.toPoint());
58 inline QPoint globalPos(QMouseEvent* event)
60 #if defined(__APPLE__)
63 CGEventRef
event = CGEventCreate(
nullptr);
64 loc = CGEventGetLocation(event);
67 return QPoint(loc.x, loc.y);
69 return event->globalPosition().toPoint();
73 inline QPointF globalPos(QWidget* viewport, QGraphicsSceneMouseEvent* event)
75 #if defined(__APPLE__)
78 CGEventRef
event = CGEventCreate(
nullptr);
79 loc = CGEventGetLocation(event);
82 return QPointF(loc.x, loc.y);
84 return viewport->mapToGlobal(QPoint{0, 0}) + event->pos();
88 #if defined(__APPLE__)
90 void hideCursor(
bool hasCursor);
96 inline void hideCursor(
bool hasCursor)
98 #if !defined(__EMSCRIPTEN__)
99 if(QGuiApplication::overrideCursor())
100 QGuiApplication::changeOverrideCursor(QCursor(Qt::BlankCursor));
102 QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
105 inline void showCursor()
107 #if !defined(__EMSCRIPTEN__)
108 QGuiApplication::restoreOverrideCursor();
Base toolkit upon which the software is built.
Definition: Application.cpp:90