Hmm, it's not quite the same... I want to have an event take place when you
click on the widget, instead of having a button in the widget. You can do
this with a stack:
Shoes.app do
stack(:width=>300, :height=>300) do
click { alert "Boo" }
end
end
But my attempts at doing it with a widget are failing miserably:
http://pastebin.com/m1f5c037a
I am running r970 now, too.
On Thu, Sep 18, 2008 at 12:14 PM, Joshua Choi <[EMAIL PROTECTED]> wrote:
> To Mr. Andrews,
>
> Well, when you're initializing the Thing object, you're passing in a
> block...but the Thing's initializer is not calling the block anywhere.
>
> The code below might have some errors, but I'm whipping it up to
> demonstrate.
>
> class Thing < Widget
>
> def initialize &block
> width = 300
> height = 300
> background blue
> yield
> end
>
> end
>
> Shoes.app do
> thing do
> button 'Test'
> para 'Testing'
> end
> end
>
> I tried running this, and it looks like it works. Mr. Why fixed a lot
> of Widget bugs in the last build, though, so make sure you have the
> latest version, Revision 970.
>
> Also note that the changing the background by a button inside the
> block only changes the button's background. I do not know if this is a
> bug—perhaps you can ask Mr. Why. :)
>
> Shoes.app do
> thing do
> button 'Test' do
> background red
> end
> para 'Testing'
> end
> end
>
> Sincerely,
> Joshua Choi
>
> On Thu, Sep 18, 2008 at 9:28 AM, Ross Andrews <[EMAIL PROTECTED]>
> wrote:
> > Hi!
> > I am trying to make a game in Shoes, and so I am making classes that are
> > custom widgets. I've got something that can draw itself, but handling
> events
> > is still eluding me.
> > Here's something like what I would like to do:
> > class Thing < Widget
> > def initialize
> > self.width=300
> > self.height=300
> > background blue
> > end
> > end
> > Shoes.app do
> > thing do
> > hover { background red }
> > leave { background blue }
> > click { alert "Ha!" }
> > end
> > end
> > Of course, it doesn't work at all (except the painting part). If I
> replace
> > "thing" with a stack, then it seems to work, so what magic is stack doing
> > that other widgets don't?
>