Hi, I think I got a problem with the FXListBox widget. ( ruby 1.8.4 (2005-12-24) [i386-mswin32]) ) FXListBox.new(parent, nil, 0) do |libo4| libo4.appendItem("0 very weird") libo4.appendItem("1 very weird") libo4.appendItem("2 very weird") libo4.appendItem("3 very weird") libo4.appendItem("4 very weird") libo4.appendItem("5 very weird") libo4.appendItem("6 very weird") libo4.appendItem("7 very weird") libo4.appendItem("8 very weird") libo4.numVisible = 6 libo4.connect(SEL_COMMAND) do |sender,selector,data| puts data end The data value printed is always 1. Not always, sometimes true, false ..... I am amazed. It''s a very common widget. I Hope I''m wrong somewhere Regards G?rard M?nochet -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20060425/552409f0/attachment.htm
lyle at knology.net
2006-Apr-25 21:56 UTC
[fxruby-users] FXListBox ...connect(SEL_COMMAND)
On Tue, 25 Apr 2006 23:48:19 +0200, G?rard M?nochet <gerard.menochet at wanadoo.fr> wrote :> I think I got a problem with the FXListBox widget...Gerard, would you please consider submitting a bug report about this? The bug tracker for FXRuby can be found here: http://rubyforge.org/tracker/index.php?group_id=300&atid=1223 Thanks, Lyle
I forgot To turn the problem around : sender.currentItem it''s ok ----- Original Message ----- From: G?rard M?nochet To: fxruby-users at rubyforge.org Sent: Tuesday, April 25, 2006 11:48 PM Subject: [fxruby-users] FXListBox ...connect(SEL_COMMAND) Hi, I think I got a problem with the FXListBox widget. ( ruby 1.8.4 (2005-12-24) [i386-mswin32]) ) FXListBox.new(parent, nil, 0) do |libo4| libo4.appendItem("0 very weird") libo4.appendItem("1 very weird") libo4.appendItem("2 very weird") libo4.appendItem("3 very weird") libo4.appendItem("4 very weird") libo4.appendItem("5 very weird") libo4.appendItem("6 very weird") libo4.appendItem("7 very weird") libo4.appendItem("8 very weird") libo4.numVisible = 6 libo4.connect(SEL_COMMAND) do |sender,selector,data| puts data end The data value printed is always 1. Not always, sometimes true, false ..... I am amazed. It''s a very common widget. I Hope I''m wrong somewhere Regards G?rard M?nochet ------------------------------------------------------------------------------ _______________________________________________ fxruby-users mailing list fxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/fxruby-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20060426/39d6e2f0/attachment.htm
On Apr 26, 2006, at 6:02 PM, G?rard M?nochet wrote:> I have the same problem. I tried to use the currentItem, > setCurrentItem() method (i guess the same thing that currentItem= ), > that > works but apparently, no call to > makeItemVisible(). (fxruby version 1.4.4 - ruby 1.8.4 - win32)I just checked the source code for FXListBox in FOX 1.4.29, and calling setCurrentItem() on an FXListBox does in fact call makeItemVisible() on the embedded FXList: // Change current item void FXListBox::setCurrentItem(FXint index){ list->setCurrentItem(index); list->makeItemVisible(index); if(0<=index){ field->setIcon(list->getItemIcon(index)); field->setText(list->getItemText(index)); } else { field->setIcon(NULL); field->setText(" "); } } Do you have an example program that demonstrates the problem? Lyle
An example libo = FXListBox.new(parent, nil, 0) libo.numVisible = 6 (1980..2050).each do |i| libo.appendItem(i.to_s) end libo.currentItem=26 No ''makeItemVisible'' at the first show. If you click one year, it will always do it . To workaround, I do that libo.connect(SEL_CONFIGURE) do |sender,selector,data| begin ; libo.currentItem = libo.currentItem ; rescue ; end # force the makeItemVisible end Thanks G?rard M?nochet ----- Original Message ----- From: "Lyle Johnson" <lyle at knology.net> To: "G?rard M?nochet" <gerard.menochet at wanadoo.fr> Cc: <fxruby-users at rubyforge.org> Sent: Thursday, April 27, 2006 2:29 AM Subject: Re: FXListBox makeItemVisible On Apr 26, 2006, at 6:02 PM, G?rard M?nochet wrote:> I have the same problem. I tried to use the currentItem, > setCurrentItem() method (i guess the same thing that currentItem= ), > that > works but apparently, no call to > makeItemVisible(). (fxruby version 1.4.4 - ruby 1.8.4 - win32)I just checked the source code for FXListBox in FOX 1.4.29, and calling setCurrentItem() on an FXListBox does in fact call makeItemVisible() on the embedded FXList: // Change current item void FXListBox::setCurrentItem(FXint index){ list->setCurrentItem(index); list->makeItemVisible(index); if(0<=index){ field->setIcon(list->getItemIcon(index)); field->setText(list->getItemText(index)); } else { field->setIcon(NULL); field->setText(" "); } } Do you have an example program that demonstrates the problem? Lyle
On Apr 26, 2006, at 8:35 PM, G?rard M?nochet wrote:> An example > > libo = FXListBox.new(parent, nil, 0) > libo.numVisible = 6 > (1980..2050).each do |i| libo.appendItem(i.to_s) end > libo.currentItem=26 > > No ''makeItemVisible'' at the first show. If you click one year, it > will > always do it .Ah, OK. Yes, I can believe that calling makeItemVisible() before the list (or list box) is actually shown probably doesn''t have any effect. I think your workaround is probably the best bet.