Subject: | Bug #12372 |
JComboBox 1.08, 5.8.7 ActiveState on Windows XP (The problem also exists on linux, as well)
The patch for 12372 is definitely necessary concerning JComboBoxes within a DialogBox. Commenting it out removes the DialogBox grab, which sucks. However, something still isn't right. After selecting an item within a JComboBox within a DialogBox, exiting the DialogBox and then selecting something in a JComboBox within MainWindow, JComboBox tries to restore focus to the last DialogBox that was opened. If the DialogBox was withdrawn, the grab will be shifted to the withdrawn window and the mainwindow will appear to be frozen (though it can still accept keyboard input I've noticed). If the DialogBox was destroyed, it will throw an error similar to:
Tk::Error: XStoSubCmd: Not a Tk Window
Tk::die_with_trace at C:/Perl/site/lib/Tk/JComboBox.pm line 562
Tk::JComboBox::hidePopup at C:/Perl/site/lib/Tk/JComboBox.pm line 1423
Tk::JComboBox::ButtonRelease at C:/Perl/site/lib/Tk.pm line 411
(eval) at C:/Perl/site/lib/Tk.pm line 411
Tk::MainLoop at test.pl line 16
Tk::die_with_trace at C:/Perl/site/lib/Tk.pm line 475
Tk::JComboBox::hidePopup at C:/Perl/site/lib/Tk/JComboBox.pm line 562
Tk::JComboBox::ButtonRelease at C:/Perl/site/lib/Tk/JComboBox.pm line 1423
<ButtonRelease-1>
(command bound to event)
Simply because it's still trying to access the destroyed dialog box. I've included a test case below. Meanwhile I'm searching through the JComboBox code myself to see if I can figure something out. If I do I'll post it, but perhaps you will find the solution before me... :)
#!/usr/bin/perl
use Tk;
use Tk::Dialog;
use Tk::JComboBox;
$mw = MainWindow->new();
$mw->idletasks;
$combo = $mw->JComboBox()->pack(-side => 'left');
$combo->addItem("Item 1");
$combo->addItem("Item 2");
$button = $mw->Button(-command => \&dialogofdeath, -text => 'Launch Dialog')->pack(-side => 'left');
MainLoop;
sub dialogofdeath
{
$dialog = $mw->DialogBox();
$newcombo = $dialog->JComboBox()->pack();
$newcombo->addItem("Item 1");
$newcombo->addItem("Item 2");
$dialog->Show();
$dialog->withdraw();
#$dialog->destroy();
}