[MacRuby-devel] Implementing Undo In RaiseMan / MacRuby

s.ross cwdinfo at gmail.com
Mon Oct 26 08:06:40 PDT 2009


John--

I've started a github repo at http://github.com/sxross/raiseman-rb,  
but it doesn't yet reflect that I can now do initial editing of an  
inserted row, but undo is not there yet.

Thanks,

Steve


On Oct 26, 2009, at 1:22 AM, John Shea wrote:

> Hi Steve,
> did you solve this one?
> if not perhaps you could post somewhere the MyDocument.rb code for  
> us to look at?
> Cheers,
> J
>
> On Sun, Oct 25, 2009 at 7:17 PM, s.ross <cwdinfo at gmail.com> wrote:
> I'm trying to implement the RaiseMan example from Aaron Hillegass's  
> book in MacRuby. All has gone pretty well until I reached undo. The  
> idea is to handle the insertObject message each time a Person is  
> inserted and manipulate the undo stack.
>
>   def insertObject(p, inEmployeesAtIndex:index)
>     NSLog("adding #{p} to #{employees}") # <= Not called, huh?
>     undo = @undoManager
>     undo.prepareWithInvocationTarget(self,  
> removeObjectFromEmployeesAtIndex:index)
>     if !undo.isUndoing
>       undo.setActionName("Insert Person")
>     end
>     employees.insertObject(p, atIndex:index)
>   end
>
> The Objective-C signature for this is:
>
> - (void)insertObject:(Person *)p inEmployeesAtIndex:(int)index
>
> Works in Objective-C but in my Ruby, the method is not recognized as  
> a handler to be invoked when a Person object is to be inserted in  
> the employees array. I should note that I created the employees  
> array using Ruby syntax:
>
> @employees ||= []
>
> Changing this to:
>
> @employees ||= NSMutableArray.alloc.init
>
> makes no difference in this scenario.
>
> Any hints with respect to what I'm missing here?
>
> Thanks,
>
> Steve
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20091026/5ad8fad9/attachment.html>


More information about the MacRuby-devel mailing list