2

I am working on a drawing app, with pen touch, on iphone and ipad. Till now , I have implemented the basic drawing and tested with digital pen and it work fine, but I have one issue, while drawing on iphone/ipad, if my fingers touch the screen before I draw with pen , the pen wont work, So what I want to achieve is that, I want to able to write with pen, even if my fingers are touching the ipad screen.

Regards Ranjit

Ranjit
  • 4,576
  • 11
  • 62
  • 121

3 Answers3

2

There is no way to differentiate between a finger and a stylus, as a stylus is supposed to emulate a touch from a finger. You will either have to make it so that all touches draw (including a hand on the screen) or make it so only the first "finger" that touches the screen can draw (meaning that you must put the stylus on the screen before your hands can touch it).

@iLive is correct in mentioning those delegate methods that you should implement, but I assume that you are already using these methods.

UPDATE:

Tracking specific touches is as simple as adding the addresses of their instances to a array during touchesBegan. Append them to a CFMutableArrayRef. Then, in the touchesMoved method, you can simply get the index of the touch in order.

C0deH4cker
  • 3,959
  • 1
  • 24
  • 35
  • hey thanks for the reply, can u please provide me any code snippets – Ranjit Jun 21 '12 at 06:04
  • Hello @C0deH4cker please help me out with this http://stackoverflow.com/questions/20761686/track-touch-points-in-mutlitouch – Ranjit Dec 30 '13 at 12:16
1

The most likely answer is in the number of touches you can receive.
Evidently, if do not enable multi-touch you will be stuck in receiving one touch at a time!
Thus, if your hand touched the screen first, then the other touches made by the digital pen will not be received.

First start by enabling the multi-touch capability.
These are the methods you will have to implement:

  • -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
  • -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
  • -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
  • -(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

Look into Apple's link: http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MultitouchEvents/MultitouchEvents.html for more information!

Hope this helped!

waylonion
  • 6,866
  • 8
  • 51
  • 92
  • hey thanks for the reply, but I am already using these functions for drawing. – Ranjit Jun 21 '12 at 06:04
  • Hello @WayWay I followed your answer and created a sample project please check out http://stackoverflow.com/questions/20761686/track-touch-points-in-mutlitouch – Ranjit Dec 30 '13 at 12:14
0

Addition You could make at least a layer (accepting no touches) coming up from the lower edge (configurable in height by the user) so that at least your palm can rest on the ipad screen surface which lowers the possibility of unwanted touches and makes drawing more stable.

Bernd Rabe
  • 790
  • 6
  • 23
  • u mean to say only the above layer will accept touch, and bottom layer will not accept touch and both will be separate.Am I right? – Ranjit Jun 26 '12 at 10:58
  • Exactly. It will act as palm rest area. It slides into place via a small button the area covered can be adjusted if its visible. Make it half opaque so that the layer below is visible. – Bernd Rabe Jun 26 '12 at 18:09