From d955d728a88a1a11ed5b9ec19633bcc173db72b8 Mon Sep 17 00:00:00 2001 From: dmitry Date: Thu, 8 Apr 2010 12:00:26 +0000 Subject: [PATCH] carbon: fixed key down/press handling, fix #16223 git-svn-id: trunk@24499 - --- lcl/interfaces/carbon/carbondef.pp | 4 ++-- lcl/interfaces/carbon/carbonedits.pp | 9 +++------ lcl/interfaces/carbon/carbonprivatewindow.inc | 20 +++++-------------- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/lcl/interfaces/carbon/carbondef.pp b/lcl/interfaces/carbon/carbondef.pp index b6861b6aed..20efcb29f1 100644 --- a/lcl/interfaces/carbon/carbondef.pp +++ b/lcl/interfaces/carbon/carbondef.pp @@ -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; diff --git a/lcl/interfaces/carbon/carbonedits.pp b/lcl/interfaces/carbon/carbonedits.pp index 6f2235694d..1123d04701 100644 --- a/lcl/interfaces/carbon/carbonedits.pp +++ b/lcl/interfaces/carbon/carbonedits.pp @@ -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; diff --git a/lcl/interfaces/carbon/carbonprivatewindow.inc b/lcl/interfaces/carbon/carbonprivatewindow.inc index 333b47d71b..aa263a5ebc 100644 --- a/lcl/interfaces/carbon/carbonprivatewindow.inc +++ b/lcl/interfaces/carbon/carbonprivatewindow.inc @@ -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