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