lcl, win32, wince: use system cut, copy, paste operations for TEdit control and descendants

git-svn-id: trunk@26480 -
This commit is contained in:
paul 2010-07-06 11:43:02 +00:00
parent 47760320eb
commit 321a2f3d30
4 changed files with 64 additions and 11 deletions

View File

@ -240,8 +240,8 @@ end;
------------------------------------------------------------------------------}
procedure TCustomEdit.CopyToClipboard;
begin
if (EchoMode = emNormal) and (SelLength > 0) then
Clipboard.AsText := SelText;
if HandleAllocated then
TWSCustomEditClass(WidgetSetClass).Copy(Self);
end;
{------------------------------------------------------------------------------
@ -253,14 +253,14 @@ end;
------------------------------------------------------------------------------}
procedure TCustomEdit.CutToClipboard;
begin
CopyToClipboard;
ClearSelection;
if HandleAllocated then
TWSCustomEditClass(WidgetSetClass).Cut(Self);
end;
procedure TCustomEdit.PasteFromClipboard;
begin
if Clipboard.HasFormat(CF_TEXT) then
SelText := Clipboard.AsText;
if HandleAllocated then
TWSCustomEditClass(WidgetSetClass).Paste(Self);
end;
procedure TCustomEdit.Undo;

View File

@ -174,6 +174,9 @@ type
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
class procedure Cut(const ACustomEdit: TCustomEdit); override;
class procedure Copy(const ACustomEdit: TCustomEdit); override;
class procedure Paste(const ACustomEdit: TCustomEdit); override;
class procedure Undo(const ACustomEdit: TCustomEdit); override;
end;
@ -1185,10 +1188,23 @@ begin
TWin32WSWinControl.SetText(ACustomEdit, AText);
end;
class procedure TWin32WSCustomEdit.Cut(const ACustomEdit: TCustomEdit);
begin
SendMessage(ACustomEdit.Handle, WM_CUT, 0, 0)
end;
class procedure TWin32WSCustomEdit.Copy(const ACustomEdit: TCustomEdit);
begin
SendMessage(ACustomEdit.Handle, WM_COPY, 0, 0)
end;
class procedure TWin32WSCustomEdit.Paste(const ACustomEdit: TCustomEdit);
begin
SendMessage(ACustomEdit.Handle, WM_PASTE, 0, 0)
end;
class procedure TWin32WSCustomEdit.Undo(const ACustomEdit: TCustomEdit);
begin
if not WSCheckHandleAllocated(ACustomEdit, 'Undo') then
Exit;
SendMessage(ACustomEdit.Handle, EM_UNDO, 0, 0)
end;

View File

@ -162,6 +162,9 @@ type
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
class procedure Cut(const ACustomEdit: TCustomEdit); override;
class procedure Copy(const ACustomEdit: TCustomEdit); override;
class procedure Paste(const ACustomEdit: TCustomEdit); override;
class procedure Undo(const ACustomEdit: TCustomEdit); override;
end;
@ -981,10 +984,23 @@ begin
EditSetSelLength(ACustomEdit.Handle, NewLength);
end;
class procedure TWinCEWSCustomEdit.Cut(const ACustomEdit: TCustomEdit);
begin
SendMessage(ACustomEdit.Handle, WM_CUT, 0, 0)
end;
class procedure TWinCEWSCustomEdit.Copy(const ACustomEdit: TCustomEdit);
begin
SendMessage(ACustomEdit.Handle, WM_COPY, 0, 0)
end;
class procedure TWinCEWSCustomEdit.Paste(const ACustomEdit: TCustomEdit);
begin
SendMessage(ACustomEdit.Handle, WM_PASTE, 0, 0)
end;
class procedure TWinCEWSCustomEdit.Undo(const ACustomEdit: TCustomEdit);
begin
if not WSCheckHandleAllocated(ACustomEdit, 'Undo') then
Exit;
SendMessage(ACustomEdit.Handle, EM_UNDO, 0, 0)
end;

View File

@ -46,7 +46,7 @@ uses
////////////////////////////////////////////////////
StdCtrls, Graphics,
////////////////////////////////////////////////////
WSLCLClasses, WSControls, Classes, WSFactory;
WSLCLClasses, WSControls, Classes, WSFactory, Clipbrd;
type
{ TWSScrollBar }
@ -157,6 +157,9 @@ type
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); virtual;
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); virtual;
class procedure Cut(const ACustomEdit: TCustomEdit); virtual;
class procedure Copy(const ACustomEdit: TCustomEdit); virtual;
class procedure Paste(const ACustomEdit: TCustomEdit); virtual;
class procedure Undo(const ACustomEdit: TCustomEdit); virtual;
end;
TWSCustomEditClass = class of TWSCustomEdit;
@ -521,6 +524,24 @@ class procedure TWSCustomEdit.SetSelLength(const ACustomEdit: TCustomEdit; NewLe
begin
end;
class procedure TWSCustomEdit.Cut(const ACustomEdit: TCustomEdit);
begin
ACustomEdit.CopyToClipboard;
ACustomEdit.ClearSelection;
end;
class procedure TWSCustomEdit.Copy(const ACustomEdit: TCustomEdit);
begin
if (ACustomEdit.EchoMode = emNormal) and (ACustomEdit.SelLength > 0) then
Clipboard.AsText := ACustomEdit.SelText;
end;
class procedure TWSCustomEdit.Paste(const ACustomEdit: TCustomEdit);
begin
if Clipboard.HasFormat(CF_TEXT) then
ACustomEdit.SelText := Clipboard.AsText;
end;
class procedure TWSCustomEdit.Undo(const ACustomEdit: TCustomEdit);
begin
// nothing