mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 18:20:05 +02:00
cocoa: propagating enabled state accross controls hierarchy #28700,#32259
git-svn-id: trunk@57080 -
This commit is contained in:
parent
7992d55d67
commit
ab151dba5a
@ -76,6 +76,7 @@ type
|
|||||||
procedure SetHasCaret(AValue: Boolean);
|
procedure SetHasCaret(AValue: Boolean);
|
||||||
function GetIsOpaque: Boolean;
|
function GetIsOpaque: Boolean;
|
||||||
procedure SetIsOpaque(AValue: Boolean);
|
procedure SetIsOpaque(AValue: Boolean);
|
||||||
|
function GetShouldBeEnabled: Boolean;
|
||||||
|
|
||||||
// properties
|
// properties
|
||||||
property HasCaret: Boolean read GetHasCaret write SetHasCaret;
|
property HasCaret: Boolean read GetHasCaret write SetHasCaret;
|
||||||
@ -115,6 +116,8 @@ type
|
|||||||
|
|
||||||
LCLViewExtension = objccategory(NSView)
|
LCLViewExtension = objccategory(NSView)
|
||||||
function lclInitWithCreateParams(const AParams: TCreateParams): id; message 'lclInitWithCreateParams:';
|
function lclInitWithCreateParams(const AParams: TCreateParams): id; message 'lclInitWithCreateParams:';
|
||||||
|
function lclIsEnabled: Boolean; message 'lclIsEnabled'; reintroduce;
|
||||||
|
procedure lclSetEnabled(AEnabled: Boolean); message 'lclSetEnabled:'; reintroduce;
|
||||||
|
|
||||||
function lclIsVisible: Boolean; message 'lclIsVisible'; reintroduce;
|
function lclIsVisible: Boolean; message 'lclIsVisible'; reintroduce;
|
||||||
procedure lclSetVisible(AVisible: Boolean); message 'lclSetVisible:'; reintroduce;
|
procedure lclSetVisible(AVisible: Boolean); message 'lclSetVisible:'; reintroduce;
|
||||||
@ -2976,7 +2979,8 @@ end;
|
|||||||
|
|
||||||
procedure LCLControlExtension.lclSetEnabled(AEnabled:Boolean);
|
procedure LCLControlExtension.lclSetEnabled(AEnabled:Boolean);
|
||||||
begin
|
begin
|
||||||
SetEnabled(AEnabled);
|
SetEnabled(AEnabled and ((not Assigned(superview)) or (superview.lclisEnabled)) );
|
||||||
|
inherited lclSetEnabled(AEnabled);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LCLViewExtension.lclInitWithCreateParams(const AParams: TCreateParams): id;
|
function LCLViewExtension.lclInitWithCreateParams(const AParams: TCreateParams): id;
|
||||||
@ -3024,6 +3028,28 @@ begin
|
|||||||
SetViewDefaults(Result);
|
SetViewDefaults(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function LCLViewExtension.lclIsEnabled: Boolean;
|
||||||
|
begin
|
||||||
|
Result := true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure LCLViewExtension.lclSetEnabled(AEnabled: Boolean);
|
||||||
|
var
|
||||||
|
ns : NSArray;
|
||||||
|
i : integer;
|
||||||
|
e : Boolean;
|
||||||
|
cb : ICommonCallback;
|
||||||
|
obj : NSObject;
|
||||||
|
begin
|
||||||
|
ns := subviews;
|
||||||
|
for i := 0 to ns.count - 1 do
|
||||||
|
begin
|
||||||
|
obj := NSObject(ns.objectAtIndex( i ));
|
||||||
|
cb := obj.lclGetCallback;
|
||||||
|
obj.lclSetEnabled(AEnabled and ((not Assigned(cb)) or cb.GetShouldBeEnabled) );
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function LCLViewExtension.lclIsVisible: Boolean;
|
function LCLViewExtension.lclIsVisible: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := not isHidden;
|
Result := not isHidden;
|
||||||
|
@ -34,6 +34,7 @@ type
|
|||||||
procedure SetHasCaret(AValue: Boolean);
|
procedure SetHasCaret(AValue: Boolean);
|
||||||
function GetIsOpaque: Boolean;
|
function GetIsOpaque: Boolean;
|
||||||
procedure SetIsOpaque(AValue: Boolean);
|
procedure SetIsOpaque(AValue: Boolean);
|
||||||
|
function GetShouldBeEnabled: Boolean;
|
||||||
protected
|
protected
|
||||||
FTarget: TWinControl;
|
FTarget: TWinControl;
|
||||||
class function CocoaModifiersToKeyState(AModifiers: NSUInteger): PtrInt; static;
|
class function CocoaModifiersToKeyState(AModifiers: NSUInteger): PtrInt; static;
|
||||||
@ -1222,6 +1223,11 @@ begin
|
|||||||
FIsOpaque:=AValue;
|
FIsOpaque:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLCLCommonCallback.GetShouldBeEnabled: Boolean;
|
||||||
|
begin
|
||||||
|
Result := Assigned(FTarget) and FTarget.Enabled;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaWSWinControl }
|
{ TCocoaWSWinControl }
|
||||||
|
|
||||||
class procedure TCocoaWSWinControl.ArrangeTabOrder(
|
class procedure TCocoaWSWinControl.ArrangeTabOrder(
|
||||||
|
Loading…
Reference in New Issue
Block a user