ly...@kn... wrote:
...
>>However if you do:
>>
>> @foo = FXCheckButton.new(p3, 'Foo',
>> nil,0).setTextColor(FXColor::Blue)
>>
>>@foo will be nil (but the color will be right)
>
>
> It's not a bug, but if you think it's something we should consider changing,
> I'm up for discussion. The effect of the second statement is that @foo gets
> assigned the result of the call to FXCheckButton#setTextColor, and that
> method currently returns nil.
It might be confusing if
btn.setTextColor(FXColor::Blue)
returns btn, but
btn.textColor = FXColor::Blue
returns FXColor::Blue, which is the current behavior.
OTOH, the set* functions in the Fox C++ API consistently are declared to
return void, which is not an option in Ruby, so I guess Lyle is free to
return something that's more useful than nil.
I kind of like the suggestion to return the receiver, so that you can
chain set* methods to operate on the same object. It gives the set*
methods a use that the corresponding attr_writers do not have, and makes
me feel better that they exist at all...
|