mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 19:19:18 +02:00
cocoa: updating key handling to allow LCL override the key character
git-svn-id: trunk@57282 -
This commit is contained in:
parent
022efcf9e9
commit
cb73fccb63
@ -1700,6 +1700,7 @@ end;
|
||||
procedure TCocoaFieldEditor.keyDown(event: NSEvent);
|
||||
var
|
||||
cb : ICommonCallback;
|
||||
res : Boolean;
|
||||
const
|
||||
NSKeyCodeTab = 48;
|
||||
begin
|
||||
@ -1708,12 +1709,13 @@ begin
|
||||
cb := lastEditBox.lclGetCallback;
|
||||
if Assigned(cb) then
|
||||
begin
|
||||
cb.KeyEvent(event);
|
||||
res := cb.KeyEvent(event);
|
||||
// LCL has already handled tab (by switching focus)
|
||||
// do not let Cocoa to switch the focus again!
|
||||
if event.keyCode = NSKeyCodeTab then Exit;
|
||||
end;
|
||||
inherited keyDown(event);
|
||||
end else
|
||||
res := false;
|
||||
if not res then inherited keyDown(event);
|
||||
end
|
||||
else
|
||||
inherited keyDown(event);
|
||||
@ -2628,9 +2630,9 @@ end;
|
||||
|
||||
procedure TCocoaTextView.keyDown(event: NSEvent);
|
||||
begin
|
||||
if Assigned(callback) then callback.KeyEvent(event);
|
||||
// don't skip inherited or else key input won't work
|
||||
inherited keyDown(event);
|
||||
if not Assigned(callback) or not callback.KeyEvent(event) then
|
||||
// don't skip inherited or else key input won't work
|
||||
inherited keyDown(event);
|
||||
end;
|
||||
|
||||
procedure TCocoaTextView.keyUp(event: NSEvent);
|
||||
|
@ -613,6 +613,8 @@ var
|
||||
end;
|
||||
end;
|
||||
|
||||
if KeyMsg.CharCode = 0 then Exit;
|
||||
|
||||
//We should send a character
|
||||
if SendChar then
|
||||
begin
|
||||
@ -643,6 +645,8 @@ var
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if CharMsg.CharCode = 0 then Exit;
|
||||
|
||||
if CharMsg.CharCode <> ord(KeyChar) then
|
||||
LCLCharToMacEvent(Char(CharMsg.CharCode));
|
||||
|
||||
@ -653,11 +657,10 @@ var
|
||||
CharMsg.Msg := LM_CHAR;
|
||||
|
||||
if DeliverMessage(CharMsg) <> 0 then
|
||||
begin
|
||||
// the LCL handled the key
|
||||
// "LN_CHAR" should be delivivered only after Cocoa processed the key
|
||||
// todo: in the current code, Cocoa has not processed the key yet
|
||||
// it must be rewritten.
|
||||
NotifyApplicationUserInput(Target, CharMsg.Msg);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
Result := False;
|
||||
end;
|
||||
@ -748,13 +751,13 @@ begin
|
||||
NSKeyDown:
|
||||
begin
|
||||
if not TranslateMacKeyCode then
|
||||
Exit(True);
|
||||
Exit(False);
|
||||
Result := HandleKeyDown;
|
||||
end;
|
||||
NSKeyUp:
|
||||
begin
|
||||
if not TranslateMacKeyCode then
|
||||
Exit(True);
|
||||
Exit(False);
|
||||
Result := HandleKeyUp;
|
||||
end;
|
||||
NSFlagsChanged:
|
||||
|
Loading…
Reference in New Issue
Block a user