[MacRuby-devel] NoMethodError for button#on_action in HotCocoa

Matt Aimonetti mattaimonetti at gmail.com
Tue Apr 21 11:43:12 PDT 2009


on_action needs to point to a block:

:on_action{l.text = "some text"}

or

:on_action => :do_stuff

def do_stuff
  Proc.new {
   puts "stuff"
}
end

You can also do:

:on_action => method(:do_stuff)

Which I believe won't require a block in your method.

- Matt


On Tue, Apr 21, 2009 at 1:39 AM, Frisco Del Rosario <
friscodelrosario at sbcglobal.net> wrote:

> I found I could fix one problem by moving the label and button declarations
> outside the layout_view block:
>
> w = window(:title => "Window", :size => [300,150])
>
> l = label(:text_align => :center, :text => "", :layout => {:expand =>
> [:width, :height], :align => "center"})
> btn = button(:title => "put some text in the label", :layout => {:align =>
> "center"})
>
> lv = layout_view :frame => [0,0,280,130], :layout => {:expand => [:width,
> :height], :align => :center, :start => true} do |view|
>  view << l
>  view << btn
> end
>
> w << lv
>
> And then the button#on_action parameter has to be in braces:
>
> btn.on_action{l.text = "some text"}
> _______________________________________________
> 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/20090421/7e57061b/attachment.html>


More information about the MacRuby-devel mailing list