class MyView < NSView
include HotCocoa::Behaviors
def drawRect(rect)
#do something...
end
end
That HotCocoa::Behaviors was what you were missing.
On Dec 3, 2008, at 12:58 AM, John Shea wrote:
Hi Ben,
thanks for your answer.
I tried that initially, but my subclass was having problems being
added to the layout view.
Anyway - somehow I got something going a little further - the
important thing was to have a create method which has :
alloc.initWithFrame([0, 0, *GameSize]) in my NSView subclass...
I did not get much further than painting black (transparency etc did
not work) - but its on the back burner while I experiment a bit more
with plain MacRuby.
Cheers and thanks,
John
On Dec 2, 2008, at 10:37 PM, Benjamin Stiglitz wrote:
I am sure there is an easy answer to this question, but I have not
figured it out after some experimenting (nor can I find an example
in the examples)
What do I do if i want to subclass (say) an NSView ? And yet still
employ that subclass with all the rest of the hot cocoa magic? (so
without using nib/xibs)
I would do this to overwrite the drawRect callback for NSView for
example - perhaps to do some animation.
class MyView < NSView
def drawRect(r)
end
end
or, even better in some cases
a = view(:something)
class << a
def drawRect(r)
end
end
-Ben
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel