cocoa: adding cocoaloopnative approach - use Cocoa natively and catch FPC exceptions within cocoa-ws

git-svn-id: trunk@61406 -
This commit is contained in:
dmitry 2019-06-17 15:14:59 +00:00
parent 55c5fcfd47
commit 3cba1d3b82
2 changed files with 16 additions and 0 deletions

View File

@ -22,6 +22,11 @@
// that Cocoa performs ALL of this methods.
{.$define COCOALOOPOVERRIDE}
// Not override "run" method. Catch any FPC exception
// The biggest problem of the Native approach - LCL "runloop" method is not called
// at all. Thus if LCL implementation is changed, CocoaWS needs to be updated
{.$define COCOALOOPNATIVE}
{$if not defined(COCOALOOPOVERRIDE) and not defined(COCOALOOPNATIVE)}
// the first call to nextEventMatchingMask_untilDate_inMode_dequeue would
// cause an LCL event processing loop to be called.

View File

@ -483,6 +483,9 @@ var
win : NSWindow;
cbnew : ICommonCallback;
begin
{$ifdef COCOALOOPNATIVE}
try
{$endif}
idx := CocoaWidgetSet.RetainToCollect;
win := theEvent.window;
if not Assigned(win) then win := self.keyWindow;
@ -542,6 +545,14 @@ begin
CocoaWidgetSet.ReleaseToCollect(idx);
end;
{$ifdef COCOALOOPNATIVE}
except
if Assigned(Application) and Application.CaptureExceptions then
Application.HandleException(Application)
else
raise;
end;
{$endif}
end;
function isMouseMoveEvent(tp: NSEventType): Boolean; inline;