• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [ANN] Coalescing undo in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ANN] Coalescing undo in Cocoa


  • Subject: Re: [ANN] Coalescing undo in Cocoa
  • From: glenn andreas <email@hidden>
  • Date: Mon, 24 Oct 2005 15:37:55 -0500


On Oct 24, 2005, at 3:15 PM, Will Thimbleby wrote:

Opps misspelt on my part, fixed now.

Because NSUndoManager groups all operations within a single cycle of the run loop, this doesn't cause a problem. However if you turn this off using setGroupsByEvent and then don't use groups --maybe. I'm not sure how NSUndoManager handles undo outside of any grouping or even if it can.

However for all normal operation it works great. The test app should show it working perfectly for you.

Will

I've seen problems where actions aren't handled by a single run loop cycle - for example, if a control uses mouseDragged: to track/perform feedback and mouseUp: to commit actions, these end up in separate run loop cycles. Since most NSControls do all their tracking in mouseDown: (or their NSCells do in their respective trackMouse:) and don't return until the mouse is released, this isn't normally a problem.


Another example where being able to coalesce undos is handy would be if you have a text field where you are typing in a number (and then since you want live feedback as you type in the number "1" "2" "3" "4" "." "5" "6" "7" you set the bindings up to continuously update). The problem is that undo ends up doing "1234.567" -> "1234.56" -> "1234.5" -> "1234." -> "1234" -> "123" -> "12" -> "1" -> back to original value that the user wanted to get to in the first place.

Surprisingly, it doesn't seem like your undo manager seems to support coalescing undos for that case (I took your example code, added a quick object controller that was connected to your view, bound the text field's value to the views size value, and altered your "change:" routine into a "setSize:" routine). Not sure why - it seems like it should (but there are probably some text field undos that are interwoven with the other undos)

I'm also not convinced that adding a method to an undocumented object to access an undocumented instance variable is the safest thing either... (since any change to AppKit that alters the layout of the ivars will cause some serious problems with your code).



Glenn Andreas                      email@hidden
 <http://www.gandreas.com/> wicked fun!
Widgetarium | the quickest path to widgets

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: [ANN] Coalescing undo in Cocoa
      • From: Will Thimbleby <email@hidden>
References: 
 >[ANN] Coalescing undo in Cocoa (From: Will Thimbleby <email@hidden>)
 >Re: [ANN] Coalescing undo in Cocoa (From: glenn andreas <email@hidden>)
 >Re: [ANN] Coalescing undo in Cocoa (From: Will Thimbleby <email@hidden>)

  • Prev by Date: Calling GetCurrentEventKeyModifiers in a Cocoa app
  • Next by Date: Problem printing a window
  • Previous by thread: Re: [ANN] Coalescing undo in Cocoa
  • Next by thread: Re: [ANN] Coalescing undo in Cocoa
  • Index(es):
    • Date
    • Thread