[Kde-bindings] Qt::Object.connect for ruby-blocks

Richard Dale rdale at foton.es
Mon Sep 4 12:43:16 UTC 2006


On Monday 04 September 2006 13:14, kelko wrote:
> Richard Dale wrote:
> > Yes, I was thinking of the other case when there are three args,
> > plus a block and it should be invoked in the context of the last
> > arg.
> >
> > @button = KDE::PushButton.new(self)
> >
> > class Foo < Qt::Object def initialize super @button =
> > KDE::PushButton.new(self) end end
> >
> > @other_button = Foo.new
> >
> > Qt::Object.connect2Block(@button, SIGNAL('clicked()'),
> > @other_button) { @button.text = "Hi" }
> >
> > Here I would expect it to set the text of the button in Foo class
> > as the target connected to the signal is an instance of Foo.
>
> I'm still thinking about that. For, if it run in the context of the
> target ( @other_button) the block could access methods and variables
> otherwise not accessible (for private or protected). Shall this be
> allowed?
Yes, it should be allowed to do everything a normal method in @other_method 
could do, and the only difference being that the block doesn't have a name, 
and it could access local variables in the calling environment too.

-- Richard



More information about the Kde-bindings mailing list