mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 21:41:35 +02:00
cocoa: update keyequivalent handler, make sure the text edit is focused. #33632
git-svn-id: trunk@58456 -
This commit is contained in:
parent
60ac1c23cc
commit
a20966155d
@ -223,6 +223,7 @@ type
|
||||
procedure lclClearCallback; override;
|
||||
procedure resetCursorRects; override;
|
||||
function lclIsHandle: Boolean; override;
|
||||
function performKeyEquivalent(event: NSEvent): Boolean; override;
|
||||
// key
|
||||
procedure keyDown(event: NSEvent); override;
|
||||
procedure keyUp(event: NSEvent); override;
|
||||
@ -1405,6 +1406,17 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function TCocoaTextView.performKeyEquivalent(event: NSEvent): Boolean;
|
||||
begin
|
||||
Result := false;
|
||||
// only respond to key, if focused
|
||||
if (not Assigned(window) or (window.firstResponder<>self)) then Exit;
|
||||
|
||||
NSResponderHotKeys(self, event, Result, self);
|
||||
if not Result then
|
||||
Result:=inherited performKeyEquivalent(event);
|
||||
end;
|
||||
|
||||
procedure TCocoaTextView.keyDown(event: NSEvent);
|
||||
begin
|
||||
if not Assigned(callback) or not callback.KeyEvent(event) then
|
||||
|
@ -97,7 +97,7 @@ function CFStringToData(AString: CFStringRef; Encoding: CFStringEncoding = DEFAU
|
||||
function GetCurrentEventTime: double;
|
||||
function GetMacOSXVersion: Integer;
|
||||
|
||||
procedure NSResponderHotKeys(trg: NSResponder; event: NSEvent; var handled: Boolean);
|
||||
procedure NSResponderHotKeys(asender: NSResponder; event: NSEvent; var handled: Boolean; atarget: id = nil);
|
||||
|
||||
function DateTimeToNSDate(const aDateTime : TDateTime): NSDate;
|
||||
function NSDateToDateTime(const aDateTime: NSDate): TDateTime;
|
||||
@ -748,7 +748,7 @@ begin
|
||||
Result := lMajor*$10000 + lMinor*$100 + lFix;
|
||||
end;
|
||||
|
||||
procedure NSResponderHotKeys(trg: NSResponder; event: NSEvent; var handled: Boolean);
|
||||
procedure NSResponderHotKeys(asender: NSResponder; event: NSEvent; var handled: Boolean; atarget: id);
|
||||
begin
|
||||
// todo: system keys could be overriden. thus need to review the current
|
||||
// keyboard configuration first. See "Key Bindings" at
|
||||
@ -762,12 +762,13 @@ begin
|
||||
if Assigned(event.charactersIgnoringModifiers.UTF8String) then
|
||||
begin
|
||||
case event.charactersIgnoringModifiers.UTF8String^ of
|
||||
'Z': handled := NSApplication(NSApp).sendAction_to_from(objcselector('redo:'), nil, trg);
|
||||
'a': handled := NSApplication(NSApp).sendAction_to_from(objcselector('selectAll:'), nil, trg);
|
||||
'c': handled := NSApplication(NSApp).sendAction_to_from(objcselector('copy:'), nil, trg);
|
||||
'v': handled := NSApplication(NSApp).sendAction_to_from(objcselector('paste:'), nil, trg);
|
||||
'x': handled := NSApplication(NSApp).sendAction_to_from(objcselector('cut:'), nil, trg);
|
||||
'z': handled := NSApplication(NSApp).sendAction_to_from(objcselector('undo:'), nil, trg);
|
||||
// redo/undo are not implemented in either of TextControls?
|
||||
//'Z': handled := NSApplication(NSApp).sendAction_to_from(objcselector('redo:'), atarget, asender);
|
||||
'a': handled := NSApplication(NSApp).sendAction_to_from(objcselector('selectAll:'), atarget, asender);
|
||||
'c': handled := NSApplication(NSApp).sendAction_to_from(objcselector('copy:'), atarget, asender);
|
||||
'v': handled := NSApplication(NSApp).sendAction_to_from(objcselector('paste:'), atarget, asender);
|
||||
'x': handled := NSApplication(NSApp).sendAction_to_from(objcselector('cut:'), atarget, asender);
|
||||
//'z': handled := NSApplication(NSApp).sendAction_to_from(objcselector('undo:'), atarget, asender);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -264,12 +264,7 @@ end;
|
||||
|
||||
function TCocoaWindowContent.performKeyEquivalent(event: NSEvent): Boolean;
|
||||
begin
|
||||
// this event servers all TextEdit, ComboBoxes and Memos on a form.
|
||||
// to do short keys for copy, paste, cut, etc...
|
||||
Result := false;
|
||||
NSResponderHotKeys(self, event, Result);
|
||||
if not Result then
|
||||
Result:=inherited performKeyEquivalent(event);
|
||||
Result:=inherited performKeyEquivalent(event);
|
||||
end;
|
||||
|
||||
procedure TCocoaWindowContent.resolvePopupParent();
|
||||
|
Loading…
Reference in New Issue
Block a user