Catch (TNT-)comboboxes in copy + paste actions. Fixes issue #1321

This commit is contained in:
Ansgar Becker
2009-08-27 13:27:39 +00:00
parent 6df4b7a706
commit a37a2af966

View File

@ -8700,6 +8700,7 @@ procedure TMainForm.actCopyOrCutExecute(Sender: TObject);
var var
Control: TWinControl; Control: TWinControl;
Edit: TCustomEdit; Edit: TCustomEdit;
Combo: TCustomComboBox;
Grid: TVirtualStringTree; Grid: TVirtualStringTree;
SynMemo: TSynMemo; SynMemo: TSynMemo;
Success, DoCut: Boolean; Success, DoCut: Boolean;
@ -8717,6 +8718,13 @@ begin
else Edit.CopyToClipboard; else Edit.CopyToClipboard;
Success := True; Success := True;
end; end;
end else if Control is TCustomComboBox then begin
Combo := TCustomComboBox(Control);
if Combo.SelLength > 0 then begin
CopyToClipboard(Combo.SelText);
if DoCut then Combo.SelText := '';
Success := True;
end;
end else if Control is TVirtualStringTree then begin end else if Control is TVirtualStringTree then begin
Grid := Control as TVirtualStringTree; Grid := Control as TVirtualStringTree;
if Assigned(Grid.FocusedNode) then begin if Assigned(Grid.FocusedNode) then begin
@ -8744,6 +8752,8 @@ procedure TMainForm.actPasteExecute(Sender: TObject);
var var
Control: TWinControl; Control: TWinControl;
Edit: TCustomEdit; Edit: TCustomEdit;
Combo: TComboBox;
TNTCombo: TTNTComboBox;
Grid: TVirtualStringTree; Grid: TVirtualStringTree;
SynMemo: TSynMemo; SynMemo: TSynMemo;
Success: Boolean; Success: Boolean;
@ -8752,6 +8762,7 @@ begin
// Paste text into the focused control // Paste text into the focused control
Success := False; Success := False;
Control := Screen.ActiveControl; Control := Screen.ActiveControl;
CB := TUniClipboard.Create;
// Do not handle Search/replace dialog // Do not handle Search/replace dialog
if not Control.Focused then Exit; if not Control.Focused then Exit;
if not Clipboard.HasFormat(CF_TEXT) then begin if not Clipboard.HasFormat(CF_TEXT) then begin
@ -8762,10 +8773,21 @@ begin
Edit.PasteFromClipboard; Edit.PasteFromClipboard;
Success := True; Success := True;
end; end;
end else if Control is TComboBox then begin
Combo := TComboBox(Control);
if Combo.Style = csDropDown then begin
Combo.SelText := CB.AsWideString;
Success := True;
end;
end else if Control is TTNTComboBox then begin
TNTCombo := TTNTComboBox(Control);
if TNTCombo.Style = csDropDown then begin
TNTCombo.SelText := CB.AsWideString;
Success := True;
end;
end else if Control is TVirtualStringTree then begin end else if Control is TVirtualStringTree then begin
Grid := Control as TVirtualStringTree; Grid := Control as TVirtualStringTree;
if Assigned(Grid.FocusedNode) and (Grid = ActiveGrid) then begin if Assigned(Grid.FocusedNode) and (Grid = ActiveGrid) then begin
CB := TUniClipboard.Create;
Grid.Text[Grid.FocusedNode, Grid.FocusedColumn] := CB.AsWideString; Grid.Text[Grid.FocusedNode, Grid.FocusedColumn] := CB.AsWideString;
Success := True; Success := True;
end; end;