[fxruby-users] associating objects with FXTable rows

Scott Willson scott at butlerpress.com
Sun Apr 2 14:21:39 EDT 2006


On Apr 2, 2006, at 5:30 AM, Mark Volkmann wrote:

> On 4/1/06, Scott Willson <scott at butlerpress.com> wrote:
>>
>> On Apr 1, 2006, at 8:11 PM, Mark Volkmann wrote:
>>
>>> I'd like to associate an arbitrary object with a row in an  
>>> FXTable. I
>>> thought I could do it using FXTableItems for my cells, but that
>>> doesn't work. Here is basically what I tried.
>>>
>>> item = FXTableItem.new(string_value, nil, some_object)
>>> table.setItem(row, column, item)
>>>
>>> some_object is an object from my ToDo class.
>>> This fails on the first line with "in `initialize': wrong argument
>>> type ToDo (expected Data)".
>>> Apparently I can't pass an arbitrary object as the last parameter of
>>> the FXTableItem constructor. What does it expect?
>>
>> Try something like this:
>> FXTableItem.new(string_value, nil) { |item|
>>    item.data = some_object
>> }
>
> Wow!  That works!  But does it make sense? I would have thought your
> code and mine would do exactly the same thing. Why can I assign to
> "data" after I've created the FXTableItem object, but I can't pass the
> same value to the FXTableItem constructor?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.

No, it doesn't make sense. It should do the same thing, though the  
two approaches could execute different code in slightly different  
contexts. I should have reported it as a bug, but I just followed the  
pattern from the examples and forgot about it.

Scott


More information about the fxruby-users mailing list