Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setAcceptsTouchEvents only works fine after a gesture on trackpad

I'm trying to use setAcceptsTouchEvents:YES to recognise custom touch events on the trackpad. Simply touching the trackpad nothing happens on the touchesBeganWithEvent. But if I do a gesture on the trackpad like pinching or scrolling the touchesBeganWithEvent starts to work properly. After one of that gestures, even if I simply touch the trackpad the touchesBeganWithEvent works. But I need to use touchesBeganWithEvent with simple touches without need to do a gesture before. The way it is seems like I have to do a gesture to initialize the setAcceptsTouchEvents:YES. What am I doing wrong?

P.S.: The setAcceptsTouchEvents:YES is in initWithFrame, and I can see that it is executed when the application starts.

like image 915
NeoRamza Avatar asked Aug 30 '12 13:08

NeoRamza


1 Answers

I found out that this problem disappears after reboot the macOS, or after just logout and login again. I tried to do anything else that could make the problem stop, like close all the applications in the macbook, switch desktops, put the OS in standby and then came back, but the only thing that makes the problem go away is to logoff or reboot the OS.

So, when the problem is gone I start my app and simply touching the trackpad the touchesBeganWithEvent is dispatched. Then after some hours the problem appears again, and touchesBeganWithEvent no more works until I do a gesture like pinching or scrolling. If I close my app and start again I need to do the gesture again.

Does anyone know why is this happening?

like image 139
NeoRamza Avatar answered Sep 19 '22 14:09

NeoRamza