• 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: Undoable controls
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undoable controls


  • Subject: Re: Undoable controls
  • From: Chris Hanson <email@hidden>
  • Date: Fri, 9 Sep 2005 00:27:52 -0700

On Sep 8, 2005, at 10:14 PM, Frode wrote:
2005-09-08 kl. 10.11 skrev Sherm Pendley:
That's not the usual way of thinking about it. Normally, undo is thought of as applying to your application's data - that is, the Model layer objects in an MVC design. The controls you're speaking of - the View layer - reflect the state of the data, and update themselves accordingly when they're notified of data changes.

In my implementation, checkboxes (NSButtons) are the actual model! :-) I don't have any special BOOL-field storing the current checkbox value; that's the checkboxes doing. If we compare text- fields or text-views, the view is normally the one storing application's data, too, in practice. Isn't it?

Typically an application's data is managed via model objects that the views are wired to via controller objects. This applies to text fields and text views just as much as it does to checkboxes and radio buttons. To use Cocoa effectively it is vitally important to understand and follow this Model-View-Controller pattern.


Now, my problem is that when the action is called, the NEW checkbox state is already set. And for mixed controls, there seems to be no method for determine the previous value from the action-callback.

This is correct, the control just needs to know about its current state. As you update your model objects' state based on actions from controls, you can easily record previous values and such.


I'm quite newbie to Cocoa Framework and after looking in Apple documentation and sample code, I can't find any issue dealing with this.

Of course, I could sub-class, introduce fields, etc. etc. but is there any easier - more smarter - way to do this? Is it possible to let the action-callback be called BEFORE the button respons to the mouse click? Or do you know any sample code dealing with this?

This is simply not how it is done in Cocoa. To use Cocoa effectively, you need to follow Model-View-Controller. Google for Cocoa MVC and you'll find a ton of references. Here's one:


<http://developer.apple.com/documentation/Cocoa/Conceptual/ AppArchitecture/Concepts/MVC.html>

  -- Chris

_______________________________________________
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


References: 
 >Undoable controls (From: Frode <email@hidden>)
 >Re: Undoable controls (From: Sherm Pendley <email@hidden>)
 >Re: Undoable controls (From: Frode <email@hidden>)

  • Prev by Date: Re: NSTableView: serious flaw when it comes to text edition? [SOLVED]
  • Next by Date: Re: Undoable controls
  • Previous by thread: Re: Undoable controls
  • Next by thread: Re: Undoable controls
  • Index(es):
    • Date
    • Thread