Ignore:
Timestamp:
Mar 19, 2010, 6:50:48 AM (14 years ago)
Author:
ronosman
Message:

Feature 1520 added : ability to set photo default caption after the photo is added.

File:
1 edited

Legend:

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

    r5041 r5184  
    4646        'Wx::CheckBox' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHECKBOX( $ctrl, $ctrl, sub { $self->OnCheckBox(@_) } ); },
    4747        'Wx::DatePickerCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_DATE_CHANGED( $ctrl, $ctrl, sub { $self->OnDatePicker(@_) } ); },
     48        'Wx::ComboBox' => sub { my ( $ctrl ) = @_;
     49                              Wx::Event::EVT_COMBOBOX( $ctrl, $ctrl, sub { $self->OnComboBox(@_) } );
     50                              Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnComboBoxText(@_) } );
     51                          },
    4852    };
    4953   
     
    8387
    8488
     89sub OnComboBoxText {
     90    my ( $self, $ctrl, $event ) = @_;
     91
     92    if( exists $ctrl->{_value}){
     93        $event->Skip(1);
     94    }
     95    else{
     96        my $id = $ctrl->GetId;
     97        # change the property value
     98        $self->properties->{$id}->{value}->(
     99            $event->GetString
     100        ) if exists $self->properties->{$id}->{value};
     101
     102        # exec the callback
     103        $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
     104            $self->properties->{$id}->{frame_callback};   
     105    }
     106
     107}
     108
     109
    85110# what does happen when the text changes
    86111sub OnTextCtrl {
     
    97122        $self->properties->{$id}->{frame_callback};   
    98123   
    99     $event->Skip;
    100124}
    101125
     
    163187    $event->Skip;
    164188}
     189
     190
     191sub OnComboBox {
     192    my ( $self, $ctrl, $event ) = @_;
     193     
     194    my $id = $ctrl->GetId;
     195
     196    $ctrl->{_multi_selection_mode} = $self->properties->{$id}->{multi_selection_mode}->()
     197        if exists $self->properties->{$id}->{multi_selection_mode};
     198
     199    my $selection = exists $self->properties->{$id}->{string_selection} ? $event->GetString : $event->GetSelection;
     200
     201    my $value = $self->properties->{$id}->{pre_process}->( $selection ) if exists
     202        $self->properties->{$id}->{pre_process};   
     203
     204    if( exists $self->properties->{$id}->{value} ){
     205        $value = $self->properties->{$id}->{value}->(
     206            $value,
     207            $selection,
     208        );
     209        # the item selected in the list is not the real value
     210        # we place here the actual value
     211        # to use in EVT_IDLE event, and overwrite the text field with it
     212        $ctrl->{_value} = $value;
     213    }
     214
     215    # exec the callback
     216    $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
     217        $self->properties->{$id}->{frame_callback};   
     218}
     219
    165220
    166221sub OnDatePicker {
     
    196251                                  $ctrl->SetValue($date);
    197252                            },
     253    'Wx::ComboBox' => sub {
     254                          my ($ctrl, $value ) = @_;
     255                          $ctrl->SetValue($value) ;
     256                      },
    198257};
    199258
     
    210269        my $ctrl =$self->FindWindow($_);
    211270        if(defined $ctrl){
     271            #printf("%s\n", $ctrl);
    212272            # checkbox, static text
    213273            $change_value->{ref $ctrl}->(
     
    269329    my ( $self ) = @_;
    270330
    271         map {
     331    map {
    272332        my $ctrl =$self->FindWindow($_);
    273333        #printf("ctrl %s : %s\n", $_, $ctrl);       
Note: See TracChangeset for help on using the changeset viewer.