diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index d6801e0bed..40d3323819 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -18,6 +18,7 @@ OBJECTIVE_SOURCES += main.mm \ qcocoamenu.mm \ qmenu_mac.mm \ qcocoahelpers.mm \ + qmultitouch_mac.mm \ HEADERS += qcocoaintegration.h \ qcocoabackingstore.h \ @@ -34,6 +35,7 @@ HEADERS += qcocoaintegration.h \ qcocoamenu.h \ qmenu_mac.h \ qcocoahelpers.h \ + qmultitouch_mac_p.h \ RESOURCES += qcocoaresources.qrc diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 7e4d4217ef..00016cb9d1 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -90,6 +90,9 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) m_contentView = [[QNSView alloc] initWithQWindow:tlw]; + // Accept touch events by default. + [m_contentView setAcceptsTouchEvents:YES]; + setGeometry(tlw->geometry()); [m_nsWindow setContentView:m_contentView]; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f3c71d9eed..f215c9df95 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -43,6 +43,7 @@ #include "qnsview.h" #include "qcocoahelpers.h" +#include "qmultitouch_mac_p.h" #include #include @@ -229,6 +230,34 @@ [self handleMouseEvent:theEvent]; } +- (void)touchesBeganWithEvent:(NSEvent *)event; +{ + const NSTimeInterval timestamp = [event timestamp]; + const QList points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false); + QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchBegin, QTouchEvent::TouchPad, points); +} + +- (void)touchesMovedWithEvent:(NSEvent *)event; +{ + const NSTimeInterval timestamp = [event timestamp]; + const QList points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false); + QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchUpdate, QTouchEvent::TouchPad, points); +} + +- (void)touchesEndedWithEvent:(NSEvent *)event; +{ + const NSTimeInterval timestamp = [event timestamp]; + const QList points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false); + QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchEnd, QTouchEvent::TouchPad, points); +} + +- (void)touchesCancelledWithEvent:(NSEvent *)event; +{ + const NSTimeInterval timestamp = [event timestamp]; + const QList points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false); + QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchEnd, QTouchEvent::TouchPad, points); +} + #ifndef QT_NO_WHEELEVENT - (void)scrollWheel:(NSEvent *)theEvent {