Changeset 6885
- Timestamp:
- 08/04/09 14:13:49 (3 years ago)
- File:
-
- 1 edited
-
trunk/Padre/lib/Padre/Wx/Editor.pm (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/Wx/Editor.pm
r6799 r6885 34 34 my $data_private; 35 35 my $width; 36 my $Clipboard_Old; 36 37 37 38 sub new { … … 63 64 Wx::Event::EVT_CHAR( $self, \&on_char ); 64 65 Wx::Event::EVT_SET_FOCUS( $self, \&on_focus ); 66 Wx::Event::EVT_MIDDLE_UP($self, \&on_middle_up ); 65 67 66 68 # Smart highlighting... … … 728 730 729 731 # Only on X11 based platforms 730 Wx::wxTheClipboard->UsePrimarySelection(1);732 # Wx::wxTheClipboard->UsePrimarySelection(1); 731 733 $self->put_text_to_clipboard($text); 732 Wx::wxTheClipboard->UsePrimarySelection(0);734 # Wx::wxTheClipboard->UsePrimarySelection(0); 733 735 } 734 736 … … 736 738 if ( $doc->can('event_on_left_up') ) { 737 739 $doc->event_on_left_up( $self, $event ); 740 } 741 742 $event->Skip; 743 return; 744 } 745 746 sub on_middle_up { 747 my ( $self, $event ) = @_; 748 749 # TODO: Sometimes there are unexpected effects when using the middle button. 750 # It seems that another event is doing something but not within this module. 751 # Please look at ticket #390 for details! 752 753 Padre::Current->editor->Paste; 754 755 my $doc = $self->{Document}; 756 if ( $doc->can('event_on_middle_up') ) { 757 $doc->event_on_middle_up( $self, $event ); 738 758 } 739 759 … … 1040 1060 } 1041 1061 1062 sub Paste { 1063 my $self = shift; 1064 1065 # Workaround for Copy/Paste bug ticket #390 1066 my $text = $self->get_text_from_clipboard; 1067 $self->ReplaceSelection($text); 1068 1069 return 1; 1070 } 1071 1042 1072 sub put_text_to_clipboard { 1043 1073 my ( $self, $text ) = @_; 1044 1074 @_ = (); # Feeble attempt to kill Scalars Leaked 1045 1075 1076 # Backup last clipboard value: 1077 $self->{Clipboard_Old} = $self->get_text_from_clipboard 1078 if $self->{Clipboard_Old} ne $self->get_text_from_clipboard; 1079 1046 1080 Wx::wxTheClipboard->Open; 1047 1081 Wx::wxTheClipboard->SetData( Wx::TextDataObject->new($text) ); … … 1053 1087 sub get_text_from_clipboard { 1054 1088 1055 # This is to be used as a method even if we don't use $self!1056 # my $self = shift; 1089 my $self = shift; 1090 1057 1091 my $text = ''; 1058 1092 Wx::wxTheClipboard->Open; … … 1060 1094 my $data = Wx::TextDataObject->new; 1061 1095 if ( Wx::wxTheClipboard->GetData($data) ) { 1062 $text = $data->GetText; 1063 } 1064 } 1096 $text = $data->GetText if defined($data); 1097 } 1098 } 1099 if ($text eq $self->GetSelectedText) { 1100 $text = $self->{Clipboard_Old}; 1101 } 1102 1065 1103 Wx::wxTheClipboard->Close; 1066 1104 return $text;
Note: See TracChangeset
for help on using the changeset viewer.
