Skip Menu |

This queue is for tickets about the Tk-JComboBox CPAN distribution.

Report information
The Basics
Id: 19154
Status: resolved
Priority: 0/
Queue: Tk-JComboBox

People
Owner: Nobody in particular
Requestors: neal
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.05
Fixed in: 1.11



Subject: configure -state=>disabled twice loses original foreground setting
If you have a jcombobox widget and set its state to disabled twice, if you then try to enable it, the color of the foreground text remains disabled. This occurs because the DisableControls sub saves the current setting of the colors without checking to see if the controls are already disabled. When DisableControls is called the 2nd time, the original saved settings are lost (they're replaced by the current 'disabled' settings). Env: Tk::JCombobox 1.10 (same code appears in 1.05 - oldest release I could find on CPAN), ActiveState Perl 5.8.8.817, WinXP SP2. I attached a file to reproduce and a patch with one way to fix. Thanks.
From: Neal
On Mon May 08 14:59:57 2006, guest wrote: Show quoted text
> If you have a jcombobox widget and set its state to disabled twice,
if Show quoted text
> you then try to enable it, the color of the foreground text remains > disabled. This occurs because the DisableControls sub saves the > current setting of the colors without checking to see if the
controls Show quoted text
> are already disabled. When DisableControls is called the 2nd time, > the original saved settings are lost (they're replaced by the > current 'disabled' settings). > > Env: Tk::JCombobox 1.10 (same code appears in 1.05 - oldest release
I Show quoted text
> could find on CPAN), ActiveState Perl 5.8.8.817, WinXP SP2. > > I attached a file to reproduce and a patch with one way to fix. > > Thanks.
#!/usr/bin/perl -w use strict; use Tk; use Tk::JComboBox; my $jcbDir; my $jcbSelected = 'a'; my @history_table = ("a","b","c"); my $top = MainWindow->new(); $jcbDir = $top->JComboBox( -mode => 'readonly', -textvariable => \$jcbSelected, -choices => \@history_table, ); $jcbDir->pack( -side => 'left', -expand => 0, -fill => "none", ); $jcbDir->configure(-state => 'disabled'); # # Following statement causes control to look # disabled, yet it still responds to events # $jcbDir->configure(-state => 'disabled'); $jcbDir->configure(-state => 'normal'); MainLoop(); exit 1;
--- old\JComboBox.pm Sun Oct 23 09:46:08 2005 +++ new\JComboBox.pm Mon May 8 14:31:16 2006 @@ -1002,19 +1002,26 @@ my $bg = $cw->cget('-disabledbackground'); my $fg = $cw->cget('-disabledforeground'); - $button->{$SWAP_FG} = $button->cget('-foreground'); - $button->configure(-foreground => $fg); - + + if ($fg ne $button->cget('-foreground')) { + $button->{$SWAP_FG} = $button->cget('-foreground'); + $button->configure(-foreground => $fg); + } + $cw->configure(-takefocus => 0); if ($cw->mode eq MODE_EDITABLE) { $entry->configure(-state => 'disabled'); return if $Tk::VERSION >= 804; - $entry->{$SWAP_BG} = $entry->cget('-background'); - $entry->configure(-background => $bg); + if ($bg ne $button->cget('-background')) { + $entry->{$SWAP_BG} = $entry->cget('-background'); + $entry->configure(-background => $bg); + } + } + if ($fg ne $button->cget('-foreground')) { + $entry->{$SWAP_FG} = $entry->cget('-foreground'); + $entry->configure(-foreground => $fg); } - $entry->{$SWAP_FG} = $entry->cget('-foreground'); - $entry->configure(-foreground => $fg); } sub EnableControls
Neal, Thanks for the patch. The bug should be resolved in version 1.11 of Tk-JComboBox. Rob
Subject: Tk-JComboBox-1.11.tar.gz
Download Tk-JComboBox-1.11.tar.gz
application/x-gzip 59.7k

Message body not shown because it is not plain text.