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? Is there another way I can associate objects with my table rows? -- R. Mark Volkmann Object Computing, Inc.
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? > > Is there another way I can associate objects with my table rows? > > -- > R. Mark Volkmann > Object Computing, Inc.Try something like this: FXTableItem.new(string_value, nil) { |item| item.data = some_object }
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.
On Apr 2, 2006, at 7:30 AM, Mark Volkmann wrote:> 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?This sounds like a bug. I''ve submitted a bug report on your behalf: http://rubyforge.org/tracker/index.php? func=detail&aid=4005&group_id=300&atid=1223 Thanks, Lyle
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