mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 00:02:50 +02:00
lcl: don't allow LCL to handle arrow keys of TCustomEdit descendants (fixes bug #0022191), handle WantTabs and WantReturn of TCustomMemo inside CM_WANTSPECIALKEY handler
git-svn-id: trunk@37689 -
This commit is contained in:
parent
29485dc359
commit
68d65a2b2c
@ -454,6 +454,15 @@ begin
|
||||
inherited WMChar(Message);
|
||||
end;
|
||||
|
||||
procedure TCustomEdit.CMWantSpecialKey(var Message: TCMWantSpecialKey);
|
||||
begin
|
||||
// don't allow LCL to handle arrow keys for edit controls
|
||||
if Message.CharCode in [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN] then
|
||||
Message.Result := 1
|
||||
else
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TCustomEdit.MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer);
|
||||
begin
|
||||
inherited MouseUp(Button, Shift, X, Y);
|
||||
|
@ -256,26 +256,13 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMemo.ControlKeyDown(var Key: Word; Shift: TShiftState);
|
||||
procedure TCustomMemo.CMWantSpecialKey(var Message: TCMWantSpecialKey);
|
||||
begin
|
||||
if not ReadOnly then
|
||||
begin
|
||||
if FWantReturns and (Key=VK_RETURN) and (Shift=[]) then
|
||||
exit;
|
||||
if FWantTabs and (Key=VK_TAB) and (Shift-[ssShift]=[]) then
|
||||
exit;
|
||||
end;
|
||||
inherited ControlKeyDown(Key, Shift);
|
||||
end;
|
||||
|
||||
procedure TCustomMemo.CNChar(var Message: TLMKeyUp);
|
||||
begin
|
||||
inherited CNChar(Message);
|
||||
|
||||
if not FWantReturns and (Message.CharCode = VK_RETURN) then
|
||||
begin
|
||||
Message.CharCode := VK_UNKNOWN;
|
||||
Message.Result := 1;
|
||||
case Message.CharCode of
|
||||
VK_RETURN: if WantReturns then Message.Result := 1;
|
||||
VK_TAB: if WantTabs then Message.Result := 1;
|
||||
else
|
||||
inherited;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -452,6 +452,7 @@ type
|
||||
TLMSysChar = TLMKey;
|
||||
TLMSysKeyDown = TLMKey;
|
||||
TLMSysKeyUp = TLMKey;
|
||||
TCMWantSpecialKey = TLMKey;
|
||||
|
||||
|
||||
TLMCut = TLMNoParams;
|
||||
|
@ -734,10 +734,12 @@ type
|
||||
procedure SetSelText(const Val: string); virtual;
|
||||
function ChildClassAllowed(ChildClass: TClass): boolean; override;
|
||||
class function GetControlClassDefaultSize: TSize; override;
|
||||
procedure KeyUpAfterInterface(var Key: Word; Shift: TShiftState); override;
|
||||
procedure WMChar(var Message: TLMChar); message LM_CHAR;
|
||||
procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer); override;
|
||||
procedure RealSetText(const AValue: TCaption); override;
|
||||
procedure KeyUpAfterInterface(var Key: Word; Shift: TShiftState); override;
|
||||
procedure WMChar(var Message: TLMChar); message LM_CHAR;
|
||||
procedure CMWantSpecialKey(var Message: TCMWantSpecialKey); message CM_WANTSPECIALKEY;
|
||||
|
||||
property AutoSelect: Boolean read FAutoSelect write FAutoSelect default True;
|
||||
property AutoSelected: Boolean read FAutoSelected write FAutoSelected;
|
||||
property ParentColor default False;
|
||||
@ -821,8 +823,7 @@ type
|
||||
procedure SetWordWrap(const Value: boolean);
|
||||
procedure SetScrollBars(const Value: TScrollStyle);
|
||||
procedure Loaded; override;
|
||||
procedure ControlKeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure CNChar(var Message: TLMKeyUp); message CN_CHAR;
|
||||
procedure CMWantSpecialKey(var Message: TCMWantSpecialKey); message CM_WANTSPECIALKEY;
|
||||
class function GetControlClassDefaultSize: TSize; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
|
Loading…
Reference in New Issue
Block a user