carbon: fixed key down/press handling, fix #16223

git-svn-id: trunk@24499 -
This commit is contained in:
dmitry 2010-04-08 12:00:26 +00:00
parent 5c3e8a2458
commit d955d728a8
3 changed files with 10 additions and 23 deletions

View File

@ -92,7 +92,7 @@ type
procedure BoundsChanged; virtual;
procedure ControlAdded; virtual;
function FilterKeyPress(SysKey: Boolean; const Char: TUTF8Char): Boolean; virtual;
procedure ProcessKeyEvent(const msg: TLMKey; var Result: OSStatus); virtual;
procedure ProcessKeyEvent(const msg: TLMKey); virtual;
function NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean; virtual;
public
constructor Create(const AObject: TWinControl; const AParams: TCreateParams);
@ -656,7 +656,7 @@ end;
Widget can perform it's own necessary actions if user has not processed the key.
It's required to emulate Command driven Carbon controls
------------------------------------------------------------------------------}
procedure TCarbonWidget.ProcessKeyEvent(const msg: TLMKey; var Result: OSStatus);
procedure TCarbonWidget.ProcessKeyEvent(const msg: TLMKey);
begin
end;

View File

@ -187,7 +187,7 @@ type
procedure TextDidChange; override;
function GetTextObject: TXNObject;
function FilterKeyPress(SysKey: Boolean; const Char: TUTF8Char): Boolean; override;
procedure ProcessKeyEvent(const msg: TLMKey; var Result: OSStatus); override;
procedure ProcessKeyEvent(const msg: TLMKey); override;
function SetTXNControl(Tag: TXNControlTag; const Data: TXNControlData): Boolean;
public
@ -1992,32 +1992,30 @@ begin
Result := False;
end;
procedure TCarbonMemo.ProcessKeyEvent(const msg: TLMKey; var Result: OSStatus);
procedure TCarbonMemo.ProcessKeyEvent(const msg: TLMKey);
var
txn : TXNObject;
begin
// CarbonEdit does action on every LM_SYSKEYDOWN
// But text view does copy/paste action only on LM_SYSUPDOWN (because HICommand is generated on KeyUp event)
// to avoid double processing (on HICommand and KeyUP event), copy/paste operations should be done on KeyDown event...
// this's actually LCL (win) memo emulation
if (msg.Msg = CN_SYSKEYDOWN) then begin
case msg.CharCode of
VK_C:
if (msg.KeyData and (MK_Shift or MK_Control) = 0) then begin
txn := GetTextObject;
if Assigned(txn) then TXNCopy(txn);
Result := noErr;
end;
VK_V:
if (msg.KeyData and (MK_Shift or MK_Control) = 0) then begin
txn := GetTextObject;
if Assigned(txn) then TXNPaste(txn);
Result := noErr;
end;
VK_X:
if (msg.KeyData and (MK_Shift or MK_Control) = 0) then begin
txn := GetTextObject;
if Assigned(txn) then TXNCut(txn);
Result := noErr;
end;
VK_Z:
if ((msg.KeyData and MK_Control) = 0) then begin
@ -2025,7 +2023,6 @@ begin
if Assigned(txn) then
if msg.KeyData and MK_Shift > 0 then TXNRedo(txn)
else TXNUndo(txn);
Result := noErr;
end;
end; {of case}
end;

View File

@ -702,12 +702,8 @@ const
end;
//Here is where we (interface) can do something with the key
//Call the standard handler.
if Result = EventNotHandledErr then begin
Widget.ProcessKeyEvent(KeyMsg, Result);
if Result = EventNotHandledErr then
Result := CallNextEventHandler(ANextHandler, AEvent);
end;
//Call the standard handler. Only Up/Down events are notified.
Widget.ProcessKeyEvent(KeyMsg);
//Send a LM_(SYS)KEYDOWN
if IsSysKey then KeyMsg.Msg := LM_SYSKEYDOWN
@ -761,12 +757,7 @@ const
Exit;
end;
//Here is where we (interface) can do something with the key
//Call the standard handler if not called already
if Result = EventNotHandledErr then begin
if Result = EventNotHandledErr then
Result := CallNextEventHandler(ANextHandler, AEvent);
end;
Result:=CallNextEventHandler(ANextHandler, AEvent);
//Send a LM_(SYS)CHAR
if IsSysKey then
@ -826,9 +817,8 @@ const
//Here is where we (interface) can do something with the key
//Call the standard handler.
Widget.ProcessKeyEvent(KeyMsg, Result);
Result := CallNextEventHandler(ANextHandler, AEvent);
Widget.ProcessKeyEvent(KeyMsg);
Result:=CallNextEventHandler(ANextHandler, AEvent);
//Send a LM_(SYS)KEYUP
if IsSysKey then KeyMsg.Msg := LM_SYSKEYUP