mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 20:56:31 +02:00
cocoa: Implements work around to support TMemo.OnClick
git-svn-id: trunk@50335 -
This commit is contained in:
parent
e99d4f997b
commit
1950d6e64d
@ -47,7 +47,7 @@ type
|
|||||||
|
|
||||||
ICommonCallback = interface
|
ICommonCallback = interface
|
||||||
// mouse events
|
// mouse events
|
||||||
function MouseUpDownEvent(Event: NSEvent): Boolean;
|
function MouseUpDownEvent(Event: NSEvent; AForceAsMouseUp: Boolean = False): Boolean;
|
||||||
procedure MouseClick;
|
procedure MouseClick;
|
||||||
function MouseMove(Event: NSEvent): Boolean;
|
function MouseMove(Event: NSEvent): Boolean;
|
||||||
function KeyEvent(Event: NSEvent; AForceAsKeyDown: Boolean = False): Boolean;
|
function KeyEvent(Event: NSEvent; AForceAsKeyDown: Boolean = False): Boolean;
|
||||||
@ -111,7 +111,6 @@ type
|
|||||||
{ LCLViewExtension }
|
{ LCLViewExtension }
|
||||||
|
|
||||||
LCLViewExtension = objccategory(NSView)
|
LCLViewExtension = objccategory(NSView)
|
||||||
|
|
||||||
function lclInitWithCreateParams(const AParams: TCreateParams): id; message 'lclInitWithCreateParams:';
|
function lclInitWithCreateParams(const AParams: TCreateParams): id; message 'lclInitWithCreateParams:';
|
||||||
|
|
||||||
function lclIsVisible: Boolean; message 'lclIsVisible'; reintroduce;
|
function lclIsVisible: Boolean; message 'lclIsVisible'; reintroduce;
|
||||||
@ -276,6 +275,7 @@ type
|
|||||||
TCocoaTextView = objcclass(NSTextView)
|
TCocoaTextView = objcclass(NSTextView)
|
||||||
public
|
public
|
||||||
callback: ICommonCallback;
|
callback: ICommonCallback;
|
||||||
|
FEnabled: Boolean;
|
||||||
function acceptsFirstResponder: Boolean; override;
|
function acceptsFirstResponder: Boolean; override;
|
||||||
function becomeFirstResponder: Boolean; override;
|
function becomeFirstResponder: Boolean; override;
|
||||||
function resignFirstResponder: Boolean; override;
|
function resignFirstResponder: Boolean; override;
|
||||||
@ -287,6 +287,21 @@ type
|
|||||||
procedure keyDown(event: NSEvent); override;
|
procedure keyDown(event: NSEvent); override;
|
||||||
procedure keyUp(event: NSEvent); override;
|
procedure keyUp(event: NSEvent); override;
|
||||||
procedure flagsChanged(event: NSEvent); override;
|
procedure flagsChanged(event: NSEvent); override;
|
||||||
|
// mouse
|
||||||
|
procedure mouseDown(event: NSEvent); override;
|
||||||
|
procedure mouseUp(event: NSEvent); override;
|
||||||
|
{procedure rightMouseDown(event: NSEvent); override;
|
||||||
|
procedure rightMouseUp(event: NSEvent); override;
|
||||||
|
procedure otherMouseDown(event: NSEvent); override;
|
||||||
|
procedure otherMouseUp(event: NSEvent); override;
|
||||||
|
|
||||||
|
procedure mouseDragged(event: NSEvent); override;
|
||||||
|
procedure mouseEntered(event: NSEvent); override;
|
||||||
|
procedure mouseExited(event: NSEvent); override;
|
||||||
|
procedure mouseMoved(event: NSEvent); override;}
|
||||||
|
//
|
||||||
|
function lclIsEnabled: Boolean; override;
|
||||||
|
procedure lclSetEnabled(AEnabled: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaPanel }
|
{ TCocoaPanel }
|
||||||
@ -1941,6 +1956,37 @@ begin
|
|||||||
inherited resetCursorRects;
|
inherited resetCursorRects;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaTextView.mouseDown(event: NSEvent);
|
||||||
|
begin
|
||||||
|
inherited mouseDown(event);
|
||||||
|
if callback <> nil then
|
||||||
|
begin
|
||||||
|
callback.MouseUpDownEvent(event);
|
||||||
|
// Cocoa doesn't call mouseUp for NSTextView, so we have to emulate it here :(
|
||||||
|
// See bug 29000
|
||||||
|
callback.MouseUpDownEvent(event, True);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaTextView.mouseUp(event: NSEvent);
|
||||||
|
begin
|
||||||
|
inherited mouseUp(event);
|
||||||
|
if callback <> nil then
|
||||||
|
callback.MouseUpDownEvent(event);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCocoaTextView.lclIsEnabled: Boolean;
|
||||||
|
begin
|
||||||
|
Result := FEnabled;
|
||||||
|
if Result and CocoaWidgetSet.IsControlDisabledDueToModal(Self) then Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaTextView.lclSetEnabled(AEnabled: Boolean);
|
||||||
|
begin
|
||||||
|
FEnabled := AEnabled;
|
||||||
|
end;
|
||||||
|
//
|
||||||
|
|
||||||
{ TCocoaSecureTextField }
|
{ TCocoaSecureTextField }
|
||||||
|
|
||||||
function TCocoaSecureTextField.lclIsHandle: Boolean;
|
function TCocoaSecureTextField.lclIsHandle: Boolean;
|
||||||
@ -2480,7 +2526,6 @@ begin
|
|||||||
Result.Bottom := Round(r.size.height);
|
Result.Bottom := Round(r.size.height);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ LCLWindowExtension }
|
{ LCLWindowExtension }
|
||||||
|
|
||||||
function LCLWindowExtension.lclIsVisible: Boolean;
|
function LCLWindowExtension.lclIsVisible: Boolean;
|
||||||
|
@ -51,7 +51,7 @@ type
|
|||||||
function GetTarget: TObject;
|
function GetTarget: TObject;
|
||||||
function GetCallbackObject: TObject;
|
function GetCallbackObject: TObject;
|
||||||
function GetCaptureControlCallback: ICommonCallBack;
|
function GetCaptureControlCallback: ICommonCallBack;
|
||||||
function MouseUpDownEvent(Event: NSEvent): Boolean; virtual;
|
function MouseUpDownEvent(Event: NSEvent; AForceAsMouseUp: Boolean = False): Boolean; virtual;
|
||||||
function KeyEvent(Event: NSEvent; AForceAsKeyDown: Boolean = False): Boolean; virtual;
|
function KeyEvent(Event: NSEvent; AForceAsKeyDown: Boolean = False): Boolean; virtual;
|
||||||
procedure MouseClick; virtual;
|
procedure MouseClick; virtual;
|
||||||
function MouseMove(Event: NSEvent): Boolean; virtual;
|
function MouseMove(Event: NSEvent): Boolean; virtual;
|
||||||
@ -108,7 +108,7 @@ type
|
|||||||
TLCLCustomControlCallback = class(TLCLCommonCallback)
|
TLCLCustomControlCallback = class(TLCLCommonCallback)
|
||||||
public
|
public
|
||||||
function MouseMove(Event: NSEvent): Boolean; override;
|
function MouseMove(Event: NSEvent): Boolean; override;
|
||||||
function MouseUpDownEvent(Event: NSEvent): Boolean; override;
|
function MouseUpDownEvent(Event: NSEvent; AForceAsMouseUp: Boolean = False): Boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaWSCustomControl }
|
{ TCocoaWSCustomControl }
|
||||||
@ -159,9 +159,9 @@ begin
|
|||||||
Result:=True;
|
Result:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLCLCustomControlCallback.MouseUpDownEvent(Event: NSEvent): Boolean;
|
function TLCLCustomControlCallback.MouseUpDownEvent(Event: NSEvent; AForceAsMouseUp: Boolean = False): Boolean;
|
||||||
begin
|
begin
|
||||||
inherited MouseUpDownEvent(Event);
|
inherited MouseUpDownEvent(Event, AForceAsMouseUp);
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -696,7 +696,7 @@ begin
|
|||||||
Result := MSGKIND[AButton][ClickCount];
|
Result := MSGKIND[AButton][ClickCount];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLCLCommonCallback.MouseUpDownEvent(Event: NSEvent): Boolean;
|
function TLCLCommonCallback.MouseUpDownEvent(Event: NSEvent; AForceAsMouseUp: Boolean = False): Boolean;
|
||||||
const
|
const
|
||||||
MSGKINDUP: array[0..3] of Integer = (LM_LBUTTONUP, LM_RBUTTONUP, LM_MBUTTONUP, LM_XBUTTONUP);
|
MSGKINDUP: array[0..3] of Integer = (LM_LBUTTONUP, LM_RBUTTONUP, LM_MBUTTONUP, LM_XBUTTONUP);
|
||||||
var
|
var
|
||||||
@ -706,6 +706,7 @@ var
|
|||||||
MButton: NSInteger;
|
MButton: NSInteger;
|
||||||
lCaptureControlCallback: ICommonCallback;
|
lCaptureControlCallback: ICommonCallback;
|
||||||
//Str: string;
|
//Str: string;
|
||||||
|
lEventType: NSEventType;
|
||||||
begin
|
begin
|
||||||
Result := False; // allow cocoa to handle message
|
Result := False; // allow cocoa to handle message
|
||||||
|
|
||||||
@ -742,8 +743,10 @@ begin
|
|||||||
MButton := 3;
|
MButton := 3;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
lEventType := Event.type_;
|
||||||
case Event.type_ of
|
if AForceAsMouseUp then
|
||||||
|
lEventType := NSLeftMouseUp;
|
||||||
|
case lEventType of
|
||||||
NSLeftMouseDown,
|
NSLeftMouseDown,
|
||||||
NSRightMouseDown,
|
NSRightMouseDown,
|
||||||
NSOtherMouseDown:
|
NSOtherMouseDown:
|
||||||
|
@ -788,6 +788,7 @@ begin
|
|||||||
nr:=scr.documentVisibleRect;
|
nr:=scr.documentVisibleRect;
|
||||||
txt.setFrame(nr);
|
txt.setFrame(nr);
|
||||||
txt.textContainer.setLineFragmentPadding(0);
|
txt.textContainer.setLineFragmentPadding(0);
|
||||||
|
txt.lclSetEnabled(True);
|
||||||
|
|
||||||
// ToDo: This should be made selectable in the LCL
|
// ToDo: This should be made selectable in the LCL
|
||||||
txt.setAutomaticQuoteSubstitutionEnabled(False);
|
txt.setAutomaticQuoteSubstitutionEnabled(False);
|
||||||
|
Loading…
Reference in New Issue
Block a user