mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-31 19:32:50 +02:00
cocoa: fix forms MouseMove sending event. Started CocoaCustomControl
git-svn-id: trunk@23914 -
This commit is contained in:
parent
540dd5ad02
commit
51501edffa
@ -125,6 +125,10 @@ type
|
||||
procedure mouseMoved(event: NSEvent); override;
|
||||
end;
|
||||
|
||||
TCocoaCustomControl = objcclass(NSControl)
|
||||
callback : TCommonCallback;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TCocoaWindowContentView }
|
||||
|
@ -8,8 +8,8 @@ interface
|
||||
uses
|
||||
MacOSAll, CocoaAll,
|
||||
Classes,
|
||||
Controls, {todo: remove controls?}
|
||||
WSControls,
|
||||
Controls,
|
||||
WSControls, LCLType,
|
||||
CocoaPrivate, CocoaUtils, LCLMessageGlue;
|
||||
|
||||
type
|
||||
@ -30,6 +30,8 @@ type
|
||||
|
||||
TCocoaWSWinControl=class(TWSWinControl)
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||
class function GetTextLen(const AWinControl: TWinControl; var ALength: Integer): Boolean; override;
|
||||
@ -40,8 +42,37 @@ type
|
||||
end;
|
||||
|
||||
|
||||
{ TCocoaWSCustomControl }
|
||||
|
||||
TCocoaWSCustomControl=class(TWSCustomControl)
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
end;
|
||||
|
||||
// Utility WS functions
|
||||
|
||||
function AllocCustomControl(const AWinControl: TWinControl): TCocoaCustomControl;
|
||||
procedure SetCreateParamsToControl(AControl: NSControl; const AParams: TCreateParams);
|
||||
|
||||
implementation
|
||||
|
||||
function AllocCustomControl(const AWinControl: TWinControl): TCocoaCustomControl;
|
||||
begin
|
||||
if not Assigned(AWinControl) then begin
|
||||
Result:=nil;
|
||||
Exit;
|
||||
end;
|
||||
Result:=TCocoaCustomControl(TCocoaCustomControl.alloc).init;
|
||||
Result.callback:=TLCLCommonCallback.Create(Result, AWinControl);
|
||||
end;
|
||||
|
||||
procedure SetCreateParamsToControl(AControl: NSControl; const AParams: TCreateParams);
|
||||
begin
|
||||
if not Assigned(AControl) then Exit;
|
||||
AddViewToNSObject(AControl, NSObject(AParams.WndParent), AParams.X, AParams.Y);
|
||||
end;
|
||||
|
||||
{ TLCLCommonCallback }
|
||||
|
||||
constructor TLCLCommonCallback.Create(AOwner: NSObject; ATarget: TControl);
|
||||
@ -72,6 +103,12 @@ end;
|
||||
|
||||
{ TCocoaWSWinControl }
|
||||
|
||||
class function TCocoaWSWinControl.CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle;
|
||||
begin
|
||||
Result:=TCocoaWSCustomControl.CreateHandle(AWinControl, AParams);
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSWinControl.SetText(const AWinControl: TWinControl; const AText: String);
|
||||
var
|
||||
obj : NSObject;
|
||||
@ -136,5 +173,17 @@ begin
|
||||
SetViewFrame(NSView(AWinControl.Handle), ALeft, ATop, AWidth, AHeight);
|
||||
end;
|
||||
|
||||
{ TCocoaWSCustomControl }
|
||||
|
||||
class function TCocoaWSCustomControl.CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle;
|
||||
var
|
||||
ctrl : TCocoaCustomControl;
|
||||
begin
|
||||
ctrl:=AllocCustomControl(AWinControl);
|
||||
SetCreateParamsToControl(ctrl, AParams);
|
||||
Result:=TLCLIntfHandle(ctrl);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -136,7 +136,8 @@ end;
|
||||
|
||||
function RegisterCustomControl: Boolean; alias : 'WSRegisterCustomControl';
|
||||
begin
|
||||
Result := False;
|
||||
RegisterWSComponent(TCustomControl, TCocoaWSCustomControl);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
// comctrls
|
||||
|
@ -28,14 +28,14 @@ unit CocoaWSForms;
|
||||
interface
|
||||
|
||||
uses
|
||||
// Libs
|
||||
MacOSAll, CocoaAll,
|
||||
// RTL,FCL
|
||||
MacOSAll, CocoaAll, Classes,
|
||||
// LCL
|
||||
Controls, {Forms, } Graphics, LCLType, LMessages, LCLProc, Classes,
|
||||
Controls, Graphics, LCLType, LMessages, LCLProc,
|
||||
// Widgetset
|
||||
WSForms, WSLCLClasses, WSProc, LCLMessageGlue,
|
||||
// LCL Cocoa
|
||||
CocoaPrivate, CocoaUtils, CocoaWSCommon, CocoaWSStdCtrls ;
|
||||
CocoaPrivate, CocoaUtils, CocoaWSCommon, CocoaWSStdCtrls;
|
||||
|
||||
type
|
||||
{ TLCLWindowCallback }
|
||||
@ -206,15 +206,18 @@ const
|
||||
WinMask = NSTitledWindowMask or NSClosableWindowMask or NSMiniaturizableWindowMask or NSResizableWindowMask;
|
||||
begin
|
||||
win := TCocoaWindow(TCocoaWindow.alloc);
|
||||
|
||||
if not Assigned(win) then begin
|
||||
Result:=0;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
win:=TCocoaWindow(win.initWithContentRect_styleMask_backing_defer(CreateParamsToNSRect(AParams), WinMask, NSBackingStoreBuffered, False));
|
||||
TCocoaWindow(win).callback:=TLCLCommonCallback.Create(win, AWinControl);
|
||||
TCocoaWindow(win).wincallback:=TLCLWindowCallback.Create(win, AWinControl);
|
||||
win.setDelegate(win);
|
||||
win.setTitle(NSStringUtf8(AWinControl.Caption));
|
||||
win.setAcceptsMouseMovedEvents(True);
|
||||
|
||||
Result := TLCLIntfHandle(win);
|
||||
end;
|
||||
|
@ -422,8 +422,7 @@ var
|
||||
btn : NSButton;
|
||||
begin
|
||||
btn:=AllocButton(AWinControl, AParams, 0, NSRadioButton);
|
||||
if Assigned(btn) then
|
||||
AddViewToNSObject(btn, NSObject(AParams.WndParent), AParams.X, AParams.Y);
|
||||
SetCreateParamsToControl(btn, AParams);
|
||||
Result:=TLCLIntfHandle(btn);
|
||||
end;
|
||||
|
||||
@ -436,8 +435,7 @@ begin
|
||||
if TCustomEdit(AWinControl).PasswordChar=#0
|
||||
then field:=NSTextField(AllocTextField(AWinControl, AParams))
|
||||
else field:=NSTextField(AllocSecureTextField(AWinControl, AParams));
|
||||
if Assigned(field) then
|
||||
AddViewToNSObject(field, NSObject(AParams.WndParent), AParams.X, AParams.Y);
|
||||
SetCreateParamsToControl(field, AParams);
|
||||
Result:=TLCLIntfHandle(field);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user