Questions tagged [nstouch]

NSTouch is a class in Objective-C. It is used to track touches on iOS devices.

An instance of the NSTouch class is a snapshot of a particular touch at an instant in time.

A touch event is not persistent throughout the touch, as new instances are created as the touch progresses. The identity property is used to follow a specific touch across its lifetime.

Touches do not have a corresponding screen location. The first touch of a touch collection is latched to the view underlying the cursor using the same hit detection as mouse events. Additional touches on the same device are also latched to the same view as any other touching touches. A touch remains latched to its view until the touch has either ended or is cancelled.

4 questions
1
vote
1 answer

How to register if finger touches (NOT pressing down as mouse button) the Apple trackpad (e.g. MacBook Pro) when using Cocos2d-X for Mac game?

All I need is to know if one finger is touching or is lifted from the trackpad. I guess I have to use NSTouch and NSTouchPhaseBegan and NSTouchPhaseEnded. This is probably a way to do it, but I don't know how to implement this Objective-C code in my…
0
votes
0 answers

How can I convert NSTouch coordinates to screen coordinates?

In Cocoa on macOS, the NSTouch object contains the coordinates of a touch in a normalized coordinate system (with x, y in the range between 0.0 and 1.0). And it also has the size of the touchpad device. So for an NSTouch object you have to…
ashcatch
  • 2,327
  • 1
  • 18
  • 29
0
votes
1 answer

Swift OS X NSTouch Phase rawInput to String?

Can't seem to print the string value of a touch phase have tried this: let phase = NSTouch.Phase(rawValue: touch.phase.rawValue) print(phase) let touches = event.touches(matching: NSTouch.Phase.ended, in: self.view) touches.forEach {…
0
votes
1 answer

How can I find the equivalent of -locationInNode for an NSTouch?

My SpriteKit Mac application responds to NSTouch events via -touchesBeganWithEvent:(NSEvent)event. However, calling -locationInNode only gives me the location of the mouse coordinate for that NSTouch. But what I'm trying to do is map the touch…
BGreenstone
  • 260
  • 1
  • 11