John--
Comments interleaved:
On Oct 27, 2009, at 4:38 AM, John Shea wrote:
Steve,
I am not sure what stage you are at with your example, I originally
did this without using an array controller, and the undoing worked
fine.
I just threw together a version with an array controller - and the
insertObject(person, inEmployeesAtIndex:index) and remove methods
are being called by the array controller - however they seem to be
passing the index as a nil. Perhaps this is what Ernest was talking
about - an unboxing issue??
Undoing initially works.
I'm not certain what to do about an unboxing issue. What I'm trying to
do is work up some muscle memory with Cocoa and translating the
prevailing Objective-C documentation to MacRuby in my head.
Selecting the second row, and then pressing insert causes a crash
into the debugger - so perhaps again some issue with what method the
array controller is calling or trying to call (and the vars it is
trying to pass) - as Ernest implied (?).
That's what I see too on the current nightly build, but not having
source limits what I can observe about this.
Note that this experiment was still with 0.4.
Perhaps it works ok in later versions?
I personally have not come across this issue before because I never
use the arraycontroller method insert and remove - I always have my
own controller methods - usually I want to check other things before
adding or removing (I believe later in the book the array controller
methods are replaced with own methods).
And this is what I do under normal circumstances. There's a ton of
magic in the wiring of this example ath the point where undo is
supposed to first start working because a good deal of stuff is done
in IB. That complicates debugging as opposed to wiring things up in
code IMO.
Not a solution but perhaps you can work around it, by using your own
controller actions, and then exploring the undo aspects?
Cheers,
John
On Mon, Oct 26, 2009 at 4:06 PM, s.ross <[email protected]> wrote:
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 <[email protected]> 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
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel