mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 13:19:30 +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 lclClearCallback; override;
|
||||||
procedure resetCursorRects; override;
|
procedure resetCursorRects; override;
|
||||||
function lclIsHandle: Boolean; override;
|
function lclIsHandle: Boolean; override;
|
||||||
|
function performKeyEquivalent(event: NSEvent): Boolean; override;
|
||||||
// key
|
// key
|
||||||
procedure keyDown(event: NSEvent); override;
|
procedure keyDown(event: NSEvent); override;
|
||||||
procedure keyUp(event: NSEvent); override;
|
procedure keyUp(event: NSEvent); override;
|
||||||
@ -1405,6 +1406,17 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
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);
|
procedure TCocoaTextView.keyDown(event: NSEvent);
|
||||||
begin
|
begin
|
||||||
if not Assigned(callback) or not callback.KeyEvent(event) then
|
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 GetCurrentEventTime: double;
|
||||||
function GetMacOSXVersion: Integer;
|
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 DateTimeToNSDate(const aDateTime : TDateTime): NSDate;
|
||||||
function NSDateToDateTime(const aDateTime: NSDate): TDateTime;
|
function NSDateToDateTime(const aDateTime: NSDate): TDateTime;
|
||||||
@ -748,7 +748,7 @@ begin
|
|||||||
Result := lMajor*$10000 + lMinor*$100 + lFix;
|
Result := lMajor*$10000 + lMinor*$100 + lFix;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure NSResponderHotKeys(trg: NSResponder; event: NSEvent; var handled: Boolean);
|
procedure NSResponderHotKeys(asender: NSResponder; event: NSEvent; var handled: Boolean; atarget: id);
|
||||||
begin
|
begin
|
||||||
// todo: system keys could be overriden. thus need to review the current
|
// todo: system keys could be overriden. thus need to review the current
|
||||||
// keyboard configuration first. See "Key Bindings" at
|
// keyboard configuration first. See "Key Bindings" at
|
||||||
@ -762,12 +762,13 @@ begin
|
|||||||
if Assigned(event.charactersIgnoringModifiers.UTF8String) then
|
if Assigned(event.charactersIgnoringModifiers.UTF8String) then
|
||||||
begin
|
begin
|
||||||
case event.charactersIgnoringModifiers.UTF8String^ of
|
case event.charactersIgnoringModifiers.UTF8String^ of
|
||||||
'Z': handled := NSApplication(NSApp).sendAction_to_from(objcselector('redo:'), nil, trg);
|
// redo/undo are not implemented in either of TextControls?
|
||||||
'a': handled := NSApplication(NSApp).sendAction_to_from(objcselector('selectAll:'), nil, trg);
|
//'Z': handled := NSApplication(NSApp).sendAction_to_from(objcselector('redo:'), atarget, asender);
|
||||||
'c': handled := NSApplication(NSApp).sendAction_to_from(objcselector('copy:'), nil, trg);
|
'a': handled := NSApplication(NSApp).sendAction_to_from(objcselector('selectAll:'), atarget, asender);
|
||||||
'v': handled := NSApplication(NSApp).sendAction_to_from(objcselector('paste:'), nil, trg);
|
'c': handled := NSApplication(NSApp).sendAction_to_from(objcselector('copy:'), atarget, asender);
|
||||||
'x': handled := NSApplication(NSApp).sendAction_to_from(objcselector('cut:'), nil, trg);
|
'v': handled := NSApplication(NSApp).sendAction_to_from(objcselector('paste:'), atarget, asender);
|
||||||
'z': handled := NSApplication(NSApp).sendAction_to_from(objcselector('undo:'), nil, trg);
|
'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;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -264,12 +264,7 @@ end;
|
|||||||
|
|
||||||
function TCocoaWindowContent.performKeyEquivalent(event: NSEvent): Boolean;
|
function TCocoaWindowContent.performKeyEquivalent(event: NSEvent): Boolean;
|
||||||
begin
|
begin
|
||||||
// this event servers all TextEdit, ComboBoxes and Memos on a form.
|
Result:=inherited performKeyEquivalent(event);
|
||||||
// to do short keys for copy, paste, cut, etc...
|
|
||||||
Result := false;
|
|
||||||
NSResponderHotKeys(self, event, Result);
|
|
||||||
if not Result then
|
|
||||||
Result:=inherited performKeyEquivalent(event);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaWindowContent.resolvePopupParent();
|
procedure TCocoaWindowContent.resolvePopupParent();
|
||||||
|
Loading…
Reference in New Issue
Block a user