Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 2    Views: 52

FromtheNE
Aspiring developer
Profile
Posts: 47
Reg: Sep 02, 2012
MA
3,220
06/03/13 07:06 PM (12 years ago)

Undo Action Method for Paint

Hello - I am looking to implement an "undo" method for the paint plugin that would allow the user to undo/clear just the very last drawing gesture (as opposed to clear all). It seems that this method would go in Paintview.m and maybe undo actions from the drawToCache method (?). I also have looked into NSUndoManager reference but I'm not sure if this would apply. Any help with coding of this method would be much appreciated. thanks!
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
06/03/13 11:42 PM (12 years ago)
This is definitely a tricky one. The current plugin code doesn't allow for this, and you'll need more than a line or two of code to do it. The "drawToCache" method simply says that the image is sent to a cache while the user's finger is on the screen, and when lifted off, it saves the image. You would need to create a property in the PaintView class to store the current image when the touchesBegan method is called (this soon becomes the previous image), and then create a custom method in the Paint.m file to override the now current image with the saved image in the property you created.
 
FromtheNE
Aspiring developer
Profile
Posts: 47
Reg: Sep 02, 2012
MA
3,220
like
06/05/13 06:17 PM (12 years ago)
Chris - thanks. Sent you a PM.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.