Changeset 5566


Ignore:
Timestamp:
Apr 2, 2010, 10:54:53 AM (15 years ago)
Author:
ronosman
Message:

Fix combobox issue on MacOS : selection is not reset after event processing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm

    r5507 r5566  
    4040    # to connect the right event handler to each control
    4141    my $ctrl_handlers = {
    42         'Wx::SpinCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_SPINCTRL( $ctrl, $ctrl, sub { $self->OnSpinCtrl(@_) } ); },
    4342        'Wx::TextCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnTextCtrl(@_) } ); },
    44         'Wx::Choice' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHOICE( $ctrl, $ctrl, sub { $self->OnChoice(@_) } ); },
     43        'Wx::Choice'   => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHOICE( $ctrl, $ctrl, sub { $self->OnChoice(@_) } ); },
    4544        'Wx::RadioBox' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_RADIOBOX( $ctrl, $ctrl, sub { $self->OnRadioBox(@_) } ); },
    4645        'Wx::CheckBox' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHECKBOX( $ctrl, $ctrl, sub { $self->OnCheckBox(@_) } ); },
    47         'Wx::DatePickerCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_DATE_CHANGED( $ctrl, $ctrl, sub { $self->OnDatePicker(@_) } ); },
     46        'Wx::SpinCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_SPINCTRL( $ctrl, $ctrl, sub { $self->OnSpinCtrl(@_) } ); },
    4847        'Wx::ComboBox' => sub { my ( $ctrl ) = @_;
    4948                              Wx::Event::EVT_COMBOBOX( $ctrl, $ctrl, sub { $self->OnComboBox(@_) } );
    5049                              Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnComboBoxText(@_) } );
    5150                          },
     51        'Wx::DatePickerCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_DATE_CHANGED( $ctrl, $ctrl, sub { $self->OnDatePicker(@_) } ); },
    5252        'Uploader::GUI::wxCategoryTreeCtrl' => sub { my ( $ctrl ) = @_;
    5353                                                   Wx::Event::EVT_TREE_SEL_CHANGED(
     
    101101
    102102    # text changed by user, not selection
    103     if( -1 eq $ctrl->GetSelection){
     103    if( $ctrl->GetValue ne $ctrl->GetStringSelection){
    104104       my $id = $ctrl->GetId;
    105105        # change the property value
    106106        $self->properties->{$id}->{value}->(
    107             $event->GetString
     107            $ctrl->GetValue
    108108        ) if exists $self->properties->{$id}->{value};
    109109
     
    116116
    117117
    118 # what does happen when the text changes
    119 sub OnTextCtrl {
    120     my ( $self, $ctrl, $event ) = @_;
    121    
    122     my $id = $ctrl->GetId;
    123     # change the property value
    124     $self->properties->{$id}->{value}->(
    125         $event->GetString
    126     ) if exists $self->properties->{$id}->{value};
    127 
    128     # exec the callback
    129     $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
    130         $self->properties->{$id}->{frame_callback};   
    131    
    132 }
    133 
    134 sub OnSpinCtrl {
    135     my ( $self, $ctrl, $event ) = @_;
    136    
    137     my $id = $ctrl->GetId;
    138     # change the property value
    139     $self->properties->{$id}->{value}->(
    140         $event->GetInt
    141     ) if exists $self->properties->{$id}->{value};
    142 
    143     # exec the callback
    144     $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
    145         $self->properties->{$id}->{frame_callback};   
    146    
    147     $event->Skip;
    148 }
    149 
    150 sub OnRadioBox {
    151     my ( $self, $ctrl, $event ) = @_;
    152    
    153     my $id = $ctrl->GetId;
    154 
    155     # if a preprocess value is required
    156     my $value = $event->GetSelection;
    157     $value = $self->properties->{$id}->{pre_process}->( $value ) if exists
    158         $self->properties->{$id}->{pre_process};   
    159     # change the property value. use the index selection
    160     $self->properties->{$id}->{selection}->(
    161         $value
    162     ) if exists $self->properties->{$id}->{selection};
    163 
    164     # exec the callback
    165     $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
    166         $self->properties->{$id}->{frame_callback};   
    167    
    168     $event->Skip;
    169 
    170 }
    171 
    172 sub OnChoice {
    173     my ( $self, $ctrl, $event ) = @_;
    174    
    175     my $id = $ctrl->GetId;
    176 
    177     # if a preprocess value is required
    178     my $value = exists $self->properties->{$id}->{string_selection} ? $event->GetString : $event->GetSelection;
    179     $value = $self->properties->{$id}->{pre_process}->( $value ) if exists
    180         $self->properties->{$id}->{pre_process};   
    181     # change the property value. use the index selection
    182     $self->properties->{$id}->{selection}->(
    183         $value
    184     ) if exists $self->properties->{$id}->{selection};
    185 
    186     # change the property value. use the string
    187     $self->properties->{$id}->{string_selection}->(
    188         $value
    189     ) if exists $self->properties->{$id}->{string_selection};
    190 
    191     # exec the callback
    192     $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
    193         $self->properties->{$id}->{frame_callback};   
    194    
    195     $event->Skip;
    196 }
    197 
    198 
    199118sub OnComboBox {
    200119    my ( $self, $ctrl, $event ) = @_;
     
    205124        if exists $self->properties->{$id}->{multi_selection_mode};
    206125
    207     my $selection = exists $self->properties->{$id}->{string_selection} ? $event->GetString : $event->GetSelection;
     126    my $selection = exists $self->properties->{$id}->{string_selection} ? $ctrl->GetValue : $ctrl->GetSelection;
    208127
    209128    my $value = $self->properties->{$id}->{pre_process}->( $selection ) if exists
     
    224143    $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
    225144        $self->properties->{$id}->{frame_callback};   
     145}
     146
     147
     148# what does happen when the text changes
     149sub OnTextCtrl {
     150    my ( $self, $ctrl, $event ) = @_;
     151   
     152    my $id = $ctrl->GetId;
     153    # change the property value
     154    $self->properties->{$id}->{value}->(
     155        $event->GetString
     156    ) if exists $self->properties->{$id}->{value};
     157
     158    # exec the callback
     159    $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
     160        $self->properties->{$id}->{frame_callback};   
     161   
     162}
     163
     164sub OnSpinCtrl {
     165    my ( $self, $ctrl, $event ) = @_;
     166   
     167    my $id = $ctrl->GetId;
     168    # change the property value
     169    $self->properties->{$id}->{value}->(
     170        $event->GetInt
     171    ) if exists $self->properties->{$id}->{value};
     172
     173    # exec the callback
     174    $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
     175        $self->properties->{$id}->{frame_callback};   
     176   
     177    $event->Skip;
     178}
     179
     180sub OnRadioBox {
     181    my ( $self, $ctrl, $event ) = @_;
     182   
     183    my $id = $ctrl->GetId;
     184
     185    # if a preprocess value is required
     186    my $value = $event->GetSelection;
     187    $value = $self->properties->{$id}->{pre_process}->( $value ) if exists
     188        $self->properties->{$id}->{pre_process};   
     189    # change the property value. use the index selection
     190    $self->properties->{$id}->{selection}->(
     191        $value
     192    ) if exists $self->properties->{$id}->{selection};
     193
     194    # exec the callback
     195    $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
     196        $self->properties->{$id}->{frame_callback};   
     197   
     198    $event->Skip;
     199
     200}
     201
     202sub OnChoice {
     203    my ( $self, $ctrl, $event ) = @_;
     204   
     205    my $id = $ctrl->GetId;
     206
     207    # if a preprocess value is required
     208    my $value = exists $self->properties->{$id}->{string_selection} ? $event->GetString : $event->GetSelection;
     209    $value = $self->properties->{$id}->{pre_process}->( $value ) if exists
     210        $self->properties->{$id}->{pre_process};   
     211    # change the property value. use the index selection
     212    $self->properties->{$id}->{selection}->(
     213        $value
     214    ) if exists $self->properties->{$id}->{selection};
     215
     216    # change the property value. use the string
     217    $self->properties->{$id}->{string_selection}->(
     218        $value
     219    ) if exists $self->properties->{$id}->{string_selection};
     220
     221    # exec the callback
     222    $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
     223        $self->properties->{$id}->{frame_callback};   
     224   
     225    $event->Skip;
    226226}
    227227
Note: See TracChangeset for help on using the changeset viewer.