diff --git a/lcl/interfaces/cocoa/cocoaint.pas b/lcl/interfaces/cocoa/cocoaint.pas index 2d82233769..c96ef4abdb 100644 --- a/lcl/interfaces/cocoa/cocoaint.pas +++ b/lcl/interfaces/cocoa/cocoaint.pas @@ -48,8 +48,8 @@ type { TCocoaTimerObject } - TCocoaTimerObject=objcclass(NSObject) - func : TWSTimerProc; + TCocoaTimerObject = objcclass(NSObject) + func: TWSTimerProc; procedure timerEvent; message 'timerEvent'; class function initWithFunc(afunc: TWSTimerProc): TCocoaTimerObject; message 'initWithFunc:'; end; @@ -66,9 +66,9 @@ type private FTerminating: Boolean; - pool : NSAutoreleasePool; - FNSApp : NSApplication; - delegate : TCocoaAppDelegate; + pool: NSAutoreleasePool; + FNSApp: NSApplication; + delegate: TCocoaAppDelegate; protected FStockNullBrush: HBRUSH; FStockBlackBrush: HBRUSH; @@ -86,6 +86,9 @@ type function GetAppHandle: THandle; override; public + // post message/ send message string + NSMessageWnd, NSMessageMsg, NSMessageWParam, NSMessageLParam, NSMessageResult: NSString; + constructor Create; override; destructor Destroy; override; @@ -106,6 +109,9 @@ type function CreateTimer(Interval: integer; TimerFunc: TWSTimerProc): THandle; override; function DestroyTimer(TimerHandle: THandle): boolean; override; + function PrepareUserEventInfo(Handle: HWND; Msg: Cardinal; wParam: WParam; + lParam: LParam): NSMutableDictionary; + function PrepareUserEvent(Handle: HWND; Info: NSDictionary): NSEvent; procedure InitStockItems; procedure FreeStockItems; diff --git a/lcl/interfaces/cocoa/cocoaobject.inc b/lcl/interfaces/cocoa/cocoaobject.inc index f7e1cf12fa..87c7a2e3e3 100644 --- a/lcl/interfaces/cocoa/cocoaobject.inc +++ b/lcl/interfaces/cocoa/cocoaobject.inc @@ -64,7 +64,7 @@ end; ------------------------------------------------------------------------------} procedure TCocoaWidgetSet.AppProcessMessages; var - event : NSEvent; + event: NSEvent; begin {$IFDEF VerboseObject} DebugLn('TCocoaWidgetSet.AppProcessMessages'); @@ -106,7 +106,14 @@ begin FTerminating := False; { Creates the AutoreleasePool } - pool := NSAutoreleasePool(NSAutoreleasePool.alloc).init; + pool := NSAutoreleasePool.alloc.init; + + NSMessageWnd := NSStringUTF8('HWND'); + NSMessageMsg := NSStringUTF8('MSG'); + NSMessageWParam := NSStringUTF8('WPARAM'); + NSMessageLParam := NSStringUTF8('LPARAM'); + NSMessageResult := NSStringUTF8('RESULT'); + InitStockItems; end; @@ -265,6 +272,59 @@ begin NSTimer(obj).invalidate; end; +function TCocoaWidgetSet.PrepareUserEventInfo(Handle: HWND; Msg: Cardinal; + wParam: WParam; lParam: LParam): NSMutableDictionary; +var + LocalPool: NSAutoReleasePool; + Keys, Objs: NSMutableArray; +begin + // create a dinctionary + LocalPool := NSAutoReleasePool.alloc.init; + Keys := NSMutableArray.arrayWithObjects( + NSMessageWnd, + NSMessageMsg, + NSMessageWParam, + NSMessageLParam, + NSMessageResult, + nil); + Objs := NSMutableArray.arrayWithObjects( + NSNumber.numberWithUnsignedInteger(Handle), + NSNumber.numberWithUnsignedLong(Msg), + NSNumber.numberWithInteger(wParam), + NSNumber.numberWithInteger(lParam), + NSNumber.numberWithInteger(0), + nil); + Result := NSMutableDictionary.dictionaryWithObjects_forKeys(Objs, Keys); + Result.retain; + // release everything + LocalPool.release; +end; + +function TCocoaWidgetSet.PrepareUserEvent(Handle: HWND; Info: NSDictionary): NSEvent; +var + Obj: NSObject; + Win: NSWindow; +begin + Obj := NSObject(Handle); + if Obj.isKindOfClass(NSWindow) then + Win := NSWindow(Obj) + else + if Obj.isKindOfClass(NSView) then + Win := NSView(Handle).window + else + Exit(nil); + Result := NSEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2( + NSApplicationDefined, + NSZeroPoint, + 0, + GetCurrentEventTime, + Win.windowNumber, + nil, + LCLEventSubTypeMessage, + NSInteger(Info), + 0); +end; + procedure TCocoaWidgetSet.InitStockItems; var LogBrush: TLogBrush; diff --git a/lcl/interfaces/cocoa/cocoaprivate.pp b/lcl/interfaces/cocoa/cocoaprivate.pp index c08e8bbb8e..9f479859fc 100644 --- a/lcl/interfaces/cocoa/cocoaprivate.pp +++ b/lcl/interfaces/cocoa/cocoaprivate.pp @@ -36,6 +36,24 @@ uses LCLType; type + { ICommonCallback } + + ICommonCallback = interface + // mouse events + procedure MouseDown(x,y: Integer); + procedure MouseUp(x,y: Integer); + procedure MouseClick(ClickCount: Integer); + procedure MouseMove(x,y: Integer); + // size,pos events + procedure frameDidChange; + procedure boundsDidChange; + // misc events + function DeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; + procedure Draw(ctx: NSGraphicsContext; const bounds, dirty: NSRect); + function GetPropStorage: TStringList; + function ResetCursorRects: Boolean; + end; + { LCLObjectExtension } LCLObjectExtension = objccategory(NSObject) @@ -53,7 +71,9 @@ type function lclFrame: TRect; message 'lclFrame'; procedure lclSetFrame(const r: TRect); message 'lclSetFrame:'; function lclClientFrame: TRect; message 'lclClientFrame'; + function lclGetCallback: ICommonCallback; message 'lclGetCallback'; function lclGetPropStorage: TStringList; message 'lclGetPropStorage'; + function lclDeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; message 'lclDeliverMessage:::'; end; { LCLViewExtension } @@ -97,23 +117,6 @@ type function lclClientFrame: TRect; message 'lclClientFrame'; reintroduce; end; - { ICommonCallback } - - ICommonCallback = interface - // mouse events - procedure MouseDown(x,y: Integer); - procedure MouseUp(x,y: Integer); - procedure MouseClick(ClickCount: Integer); - procedure MouseMove(x,y: Integer); - // size,pos events - procedure frameDidChange; - procedure boundsDidChange; - // misc events - procedure Draw(ctx: NSGraphicsContext; const bounds, dirty: NSRect); - function GetPropStorage: TStringList; - function ResetCursorRects: Boolean; - end; - { IButtonCallback } IButtonCallback = interface(ICommonCallback) @@ -156,7 +159,7 @@ type callback: IButtonCallback; function initWithFrame(frameRect: NSRect): id; override; function acceptsFirstResponder: Boolean; override; - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; procedure mouseDown(event: NSEvent); override; procedure mouseDragged(event: NSEvent); override; procedure mouseEntered(event: NSEvent); override; @@ -171,7 +174,7 @@ type TCocoaTextField = objcclass(NSTextField) callback: ICommonCallback; function acceptsFirstResponder: Boolean; override; - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; procedure resetCursorRects; override; end; @@ -189,7 +192,7 @@ type TCocoaTextView = objcclass(NSTextView) callback: ICommonCallback; function acceptsFirstResponder: Boolean; override; - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; procedure resetCursorRects; override; end; @@ -206,13 +209,14 @@ type public callback: IWindowCallback; function acceptsFirstResponder: Boolean; override; - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; procedure mouseUp(event: NSEvent); override; procedure mouseDown(event: NSEvent); override; procedure mouseDragged(event: NSEvent); override; procedure mouseEntered(event: NSEvent); override; procedure mouseExited(event: NSEvent); override; procedure mouseMoved(event: NSEvent); override; + procedure sendEvent(event: NSEvent); override; end; { TCocoaCustomControl } @@ -220,7 +224,7 @@ type TCocoaCustomControl = objcclass(NSControl) callback: ICommonCallback; procedure drawRect(dirtyRect: NSRect); override; - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; procedure mouseDown(event: NSEvent); override; procedure mouseDragged(event: NSEvent); override; procedure mouseEntered(event: NSEvent); override; @@ -234,7 +238,7 @@ type TCocoaScrollView = objcclass(NSScrollView) callback: ICommonCallback; - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; procedure resetCursorRects; override; end; @@ -271,7 +275,7 @@ type function numberOfItemsInComboBox(combo: TCocoaComboBox): NSInteger; message 'numberOfItemsInComboBox:'; procedure dealloc; override; - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; procedure resetCursorRects; override; procedure comboBoxWillPopUp(notification: NSNotification); message 'comboBoxWillPopUp:'; procedure comboBoxWillDismiss(notification: NSNotification); message 'comboBoxWillDismiss:'; @@ -283,7 +287,7 @@ type TCocoaScrollBar = objcclass(NSScroller) callback: ICommonCallback; - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; procedure resetCursorRects; override; end; @@ -305,7 +309,7 @@ type callback: ICommonCallback; list: TCocoaStringList; resultNS: NSString; //use to return values to combo - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; function numberOfRowsInTableView(aTableView: NSTableView): NSInteger; message 'numberOfRowsInTableView:'; function tableView_objectValueForTableColumn_row(tableView: NSTableView; objectValueForTableColumn: NSTableColumn; row: NSInteger):id; @@ -318,17 +322,20 @@ type TCocoaGroupBox = objcclass(NSBox) callback: ICommonCallback; - function lclGetPropStorage: TStringList; override; + function lclGetCallback: ICommonCallback; override; procedure resetCursorRects; override; end; implementation +uses + CocoaInt; + { TCocoaScrollView } -function TCocoaScrollView.lclGetPropStorage: TStringList; +function TCocoaScrollView.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; procedure TCocoaScrollView.resetCursorRects; @@ -339,9 +346,9 @@ end; { TCocoaScrollBar } -function TCocoaScrollBar.lclGetPropStorage: TStringList; +function TCocoaScrollBar.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; procedure TCocoaScrollBar.resetCursorRects; @@ -352,9 +359,9 @@ end; { TCocoaGroupBox } -function TCocoaGroupBox.lclGetPropStorage: TStringList; +function TCocoaGroupBox.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; procedure TCocoaGroupBox.resetCursorRects; @@ -400,9 +407,9 @@ begin Result := True; end; -function TCocoaButton.lclGetPropStorage: TStringList; +function TCocoaButton.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; procedure TCocoaButton.mouseUp(event: NSEvent); @@ -453,12 +460,12 @@ end; function TCocoaTextField.acceptsFirstResponder: Boolean; begin - Result:=true; + Result := True; end; -function TCocoaTextField.lclGetPropStorage: TStringList; +function TCocoaTextField.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; procedure TCocoaTextField.resetCursorRects; @@ -474,12 +481,12 @@ end; function TCocoaTextView.acceptsFirstResponder: Boolean; begin - Result:=true; + Result := True; end; -function TCocoaTextView.lclGetPropStorage: TStringList; +function TCocoaTextView.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; procedure TCocoaTextView.resetCursorRects; @@ -529,9 +536,9 @@ begin Result := True; end; -function TCocoaWindow.lclGetPropStorage: TStringList; +function TCocoaWindow.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; procedure TCocoaWindow.mouseUp(event: NSEvent); @@ -574,6 +581,39 @@ begin inherited mouseMoved(event); end; +procedure TCocoaWindow.sendEvent(event: NSEvent); +var + Message: NSMutableDictionary; + Handle: HWND; + Msg: Cardinal; + WP: WParam; + LP: LParam; + Result: NSNumber; + Obj: NSObject; +begin + if event.type_ = NSApplicationDefined then + begin + // event which we get through PostMessage or SendMessage + if event.subtype = LCLEventSubTypeMessage then + begin + // extract message data + Message := NSMutableDictionary(event.data1); + Handle := NSNumber(Message.objectForKey(CocoaWidgetSet.NSMessageWnd)).unsignedIntegerValue; + Msg := NSNumber(Message.objectForKey(CocoaWidgetSet.NSMessageMsg)).unsignedLongValue; + WP := NSNumber(Message.objectForKey(CocoaWidgetSet.NSMessageWParam)).integerValue; + LP := NSNumber(Message.objectForKey(CocoaWidgetSet.NSMessageLParam)).integerValue; + // deliver message and set result + Obj := NSObject(Handle); + // todo: check that Obj is still a valid NSView/NSWindow + Result := NSNumber.numberWithInteger(Obj.lclDeliverMessage(Msg, WP, LP)); + Message.setObject_forKey(Result, CocoaWidgetSet.NSMessageResult); + Result.release; + end; + end + else + inherited sendEvent(event); +end; + procedure TCocoaWindow.mouseEntered(event: NSEvent); begin inherited mouseEntered(event); @@ -605,9 +645,9 @@ begin callback.Draw(NSGraphicsContext.currentContext, bounds, dirtyRect); end; -function TCocoaCustomControl.lclGetPropStorage: TStringList; +function TCocoaCustomControl.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; procedure TCocoaCustomControl.mouseDown(event: NSEvent); @@ -709,11 +749,33 @@ begin FillChar(Result, sizeof(Result), 0); end; -function LCLObjectExtension.lclGetPropStorage: TStringList; +function LCLObjectExtension.lclGetCallback: ICommonCallback; begin Result := nil; end; +function LCLObjectExtension.lclGetPropStorage: TStringList; +var + Callback: ICommonCallback; +begin + Callback := lclGetCallback; + if Assigned(Callback) then + Result := Callback.GetPropStorage + else + Result := nil; +end; + +function LCLObjectExtension.lclDeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; +var + Callback: ICommonCallback; +begin + Callback := lclGetCallback; + if Assigned(Callback) then + Result := Callback.DeliverMessage(Msg, WParam, LParam) + else + Result := 0; +end; + { LCLControlExtension } function RectToViewCoord(view: NSView; const r: TRect): NSRect; @@ -939,9 +1001,9 @@ end; { TCocoaListView } -function TCocoaListView.lclGetPropStorage: TStringList; +function TCocoaListView.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; function TCocoaListView.numberOfRowsInTableView(aTableView:NSTableView): NSInteger; @@ -1035,9 +1097,9 @@ begin inherited dealloc; end; -function TCocoaComboBox.lclGetPropStorage: TStringList; +function TCocoaComboBox.lclGetCallback: ICommonCallback; begin - Result := callback.GetPropStorage; + Result := callback; end; procedure TCocoaComboBox.resetCursorRects; diff --git a/lcl/interfaces/cocoa/cocoautils.pas b/lcl/interfaces/cocoa/cocoautils.pas index 65ababcd79..c8d2207507 100644 --- a/lcl/interfaces/cocoa/cocoautils.pas +++ b/lcl/interfaces/cocoa/cocoautils.pas @@ -9,6 +9,9 @@ uses MacOSAll, CocoaAll, Types, LCLType; +const + LCLEventSubTypeMessage = MaxShort - 1; + type { NSLCLDebugExtension } diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index 477325a050..1c19cea75a 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -46,6 +46,31 @@ const { crt_Complex } COMPLEXREGION ); +function TCocoaWidgetSet.Arc(DC: HDC; Left, Top, Right, Bottom, angle1, + angle2: Integer): Boolean; +begin + Result:=inherited Arc(DC, Left, Top, Right, Bottom, angle1, angle2); +end; + +function TCocoaWidgetSet.AngleChord(DC: HDC; x1, y1, x2, y2, angle1, + angle2: Integer): Boolean; +begin + Result:=inherited AngleChord(DC, x1, y1, x2, y2, angle1, angle2); +end; + +function TCocoaWidgetSet.BeginPaint(Handle: hWnd; var PS: TPaintStruct): hdc; +begin + Result := inherited BeginPaint(Handle, PS); + PS.hdc := Result; +end; + +function TCocoaWidgetSet.BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; + SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean; +begin + Result := StretchMaskBlt(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, + Width, Height, 0, 0, 0, Rop); +end; + function TCocoaWidgetSet.ClientToScreen(Handle: HWND; var P: TPoint): Boolean; begin Result := Handle <> 0; @@ -337,6 +362,11 @@ begin NSObject(hWnd).lclSetEnabled(bEnable) end; +function TCocoaWidgetSet.EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; +begin + Result:=inherited EndPaint(Handle, PS); +end; + function TCocoaWidgetSet.EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; var @@ -1115,6 +1145,23 @@ begin Result:=True; end; +function TCocoaWidgetSet.PostMessage(Handle: HWND; Msg: Cardinal; + wParam: WParam; lParam: LParam): Boolean; +var + Info: NSDictionary; + Event: NSEvent; +begin + Result := Handle <> 0; + if Result then + begin + Info := PrepareUserEventInfo(Handle, Msg, WParam, LParam); + // if we will want a postmessage using notification center + // NSDistributedNotificationCenter.defaultCenter.postNotificationName_object_userInfo_deliverImmediately(NSMessageNotification, nil, Info, False); + Event := PrepareUserEvent(Handle, Info); + NSApp.postEvent_atStart(Event, False); + end; +end; + function TCocoaWidgetSet.Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean; var ctx: TCocoaContext; @@ -1324,6 +1371,21 @@ begin {$ENDIF} end; +function TCocoaWidgetSet.SendMessage(Handle: HWND; Msg: Cardinal; + WParam: WParam; LParam: LParam): LResult; +var + Info: NSDictionary; + Event: NSEvent; +begin + if Handle <> 0 then + begin + Info := PrepareUserEventInfo(Handle, Msg, WParam, LParam); + Event := PrepareUserEvent(Handle, Info); + NSApp.sendEvent(Event); + Result := NSNumber(Info.objectForKey(NSMessageResult)).integerValue; + end; +end; + function TCocoaWidgetSet.SetActiveWindow(Handle: HWND): HWND; var Obj: NSObject; diff --git a/lcl/interfaces/cocoa/cocoawinapih.inc b/lcl/interfaces/cocoa/cocoawinapih.inc index d0a4150544..fc93a922a3 100644 --- a/lcl/interfaces/cocoa/cocoawinapih.inc +++ b/lcl/interfaces/cocoa/cocoawinapih.inc @@ -27,13 +27,13 @@ //##apiwiz##sps## // Do not remove, no wizard declaration before this line -//function Arc(DC: HDC; Left,Top,Right,Bottom,angle1,angle2 : Integer): Boolean; override; -//function AngleChord(DC: HDC; x1, y1, x2, y2, angle1, angle2: Integer): Boolean; override; +function Arc(DC: HDC; Left,Top,Right,Bottom,angle1,angle2 : Integer): Boolean; override; +function AngleChord(DC: HDC; x1, y1, x2, y2, angle1, angle2: Integer): Boolean; override; -{function BeginPaint(Handle: hWnd; Var PS : TPaintStruct) : hdc; override; +function BeginPaint(Handle: hWnd; Var PS : TPaintStruct) : hdc; override; function BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean; override; -function CallNextHookEx(hHk: HHOOK; ncode : Integer; wParam: WParam; lParam : LParam) : Integer; override; +{function CallNextHookEx(hHk: HHOOK; ncode : Integer; wParam: WParam; lParam : LParam) : Integer; override; function CallWindowProc(lpPrevWndFunc : TFarProc; Handle : HWND; Msg : UINT; wParam: WParam; lParam : lParam) : Integer; override;} function ClientToScreen(Handle: HWND; var P: TPoint) : Boolean; override; { @@ -74,7 +74,7 @@ function DrawEdge(DC: HDC; var Rect: TRect; edge: Cardinal; grfFlags: Cardinal): function Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean; override; {function EnableScrollBar(Wnd: HWND; wSBflags, wArrows: Cardinal): Boolean; override;} function EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean; override; -{function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override;} +function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override; procedure EnterCriticalSection(var CritSection: TCriticalSection); override; function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override; function EnumDisplayMonitors(hdc: HDC; lprcClip: PRect; lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool; override; @@ -150,7 +150,7 @@ function MoveWindowOrgEx(DC: HDC; dX, dY: Integer): Boolean; override; function PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer; Filled, Continuous: boolean): boolean; override;} function Polygon(DC: HDC; Points: PPoint; NumPts: Integer; Winding: boolean): boolean; override; function Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean; override; -{function PostMessage(Handle: HWND; Msg: Cardinal; wParam: WParam; lParam: LParam): Boolean; override;} +function PostMessage(Handle: HWND; Msg: Cardinal; wParam: WParam; lParam: LParam): Boolean; override; function Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean; override; function RectVisible(dc : hdc; const ARect: TRect) : Boolean; override; @@ -163,7 +163,7 @@ function SaveDC(DC: HDC): Integer; override; function ScreenToClient(Handle: HWND; var P: TPoint): Integer; override; function SelectClipRGN(DC : hDC; RGN : HRGN) : Longint; override; function SelectObject(ADC: HDC; GDIObj: HGDIOBJ): HGDIOBJ; override; -{function SendMessage(HandleWnd: HWND; Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; override;} +function SendMessage(Handle: HWND; Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; override; function SetActiveWindow(Handle: HWND): HWND; override; function SetBKColor(DC: HDC; Color: TColorRef): TColorRef; override; function SetBkMode(DC: HDC; bkMode : Integer) : Integer; override; diff --git a/lcl/interfaces/cocoa/cocoawscommon.pas b/lcl/interfaces/cocoa/cocoawscommon.pas index 1a5f25d7f7..f687f51935 100644 --- a/lcl/interfaces/cocoa/cocoawscommon.pas +++ b/lcl/interfaces/cocoa/cocoawscommon.pas @@ -39,6 +39,7 @@ type procedure MouseMove(x,y: Integer); virtual; procedure frameDidChange; virtual; procedure boundsDidChange; virtual; + function DeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; virtual; procedure Draw(ControlContext: NSGraphicsContext; const bounds, dirty: NSRect); virtual; function ResetCursorRects: Boolean; virtual; end; @@ -187,7 +188,7 @@ begin cy := NewBounds.Bottom - NewBounds.Top; flags := 0; end; - DeliverMessage(Target, PosMsg); + LCLMessageGlue.DeliverMessage(Target, PosMsg); finally Dispose(PosMsg.WindowPos); end; @@ -225,6 +226,17 @@ begin end; end; +function TLCLCommonCallback.DeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; +var + Message: TLMessage; +begin + Message.Msg := Msg; + Message.WParam := WParam; + Message.LParam := LParam; + Message.Result := 0; + Result := LCLMessageGlue.DeliverMessage(Target, Message); +end; + procedure TLCLCommonCallback.Draw(ControlContext: NSGraphicsContext; const bounds, dirty:NSRect); var