SetAcceptsTouchEvents only works after gestures on the trackpad.

I am trying to use setAcceptsTouchEvents:YESto recognize custom touch events on the trackpad. Just touch the trackpad nothing happens on touchesBeganWithEvent. But if I make a gesture on the trackpad, for example, pinching or scrolling, it touchesBeganWithEventwill start working correctly. After one of these gestures, even if I just touch the trackpad, it works touchesBeganWithEvent. But I need to use it touchesBeganWithEventwith simple touches, without having to make a gesture earlier. It seems to me that I should make a gesture to initialize setAcceptsTouchEvents:YES. What am I doing wrong?

PS: setAcceptsTouchEvents:YESlocated in initWithFrame, and I see that it runs when the application starts.

+5
source share
2 answers

I found out that this problem disappears after rebooting macOS or after logging out and logging in again. I tried to do something else that could stop this problem, such as closing all applications on a macbook, switching desktops, putting the OS into standby mode and then returning, but the only thing that makes the problem go away is to log out or restart the computer OS

So, when the problem disappeared, I launch my application and just touch the trackpad that sends touchsBeganWithEvent. Then after a few hours, the problem reappears, and touchBeganWithEvent no longer works until I make a gesture like squeezing or scrolling. If I close my application and start again, I need to make a gesture again.

Does anyone know why this is happening?

+3

docs:

. , ( ) [event touchesMatchingPhase: NSTouchPhaseBegan INview.: ]

:

  • , , .
  • , BeganWithEvent.
+2

All Articles