mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 10:36:01 +02:00
cocoa: hot keys handling for windowcontent view #33072
git-svn-id: trunk@57154 -
This commit is contained in:
parent
756867c662
commit
96d01f3f8f
@ -503,6 +503,7 @@ type
|
|||||||
ownwin: NSWindow;
|
ownwin: NSWindow;
|
||||||
popup_parent: HWND; // if not 0, indicates that we should set the popup parent
|
popup_parent: HWND; // if not 0, indicates that we should set the popup parent
|
||||||
overlay: NSView;
|
overlay: NSView;
|
||||||
|
function performKeyEquivalent(event: NSEvent): Boolean; override;
|
||||||
procedure resolvePopupParent(); message 'resolvePopupParent';
|
procedure resolvePopupParent(); message 'resolvePopupParent';
|
||||||
function lclOwnWindow: NSWindow; message 'lclOwnWindow';
|
function lclOwnWindow: NSWindow; message 'lclOwnWindow';
|
||||||
procedure lclSetFrame(const r: TRect); override;
|
procedure lclSetFrame(const r: TRect); override;
|
||||||
@ -1359,6 +1360,16 @@ begin
|
|||||||
callback.DidResignKeyNotification;
|
callback.DidResignKeyNotification;
|
||||||
end;
|
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);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCocoaWindowContent.resolvePopupParent();
|
procedure TCocoaWindowContent.resolvePopupParent();
|
||||||
var
|
var
|
||||||
lWindow: NSWindow;
|
lWindow: NSWindow;
|
||||||
|
@ -95,6 +95,8 @@ 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);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure ColorToRGBFloat(cl: TColorRef; var r,g,b: Single); inline;
|
procedure ColorToRGBFloat(cl: TColorRef; var r,g,b: Single); inline;
|
||||||
@ -699,5 +701,30 @@ begin
|
|||||||
Result := lMajor*$10000 + lMinor*$100 + lFix;
|
Result := lMajor*$10000 + lMinor*$100 + lFix;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure NSResponderHotKeys(trg: NSResponder; event: NSEvent; var handled: Boolean);
|
||||||
|
begin
|
||||||
|
// todo: system keys could be overriden. thus need to review the current
|
||||||
|
// keyboard configuration first. See "Key Bindings" at
|
||||||
|
// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html
|
||||||
|
|
||||||
|
handled := false;
|
||||||
|
if (event.type_ = NSKeyDown) then
|
||||||
|
begin
|
||||||
|
if ((event.modifierFlags and NSCommandKeyMask) = 0) then Exit;
|
||||||
|
|
||||||
|
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);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user