mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 15:00:26 +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);
|
||||
function GetIsOpaque: Boolean;
|
||||
procedure SetIsOpaque(AValue: Boolean);
|
||||
function GetShouldBeEnabled: Boolean;
|
||||
|
||||
// properties
|
||||
property HasCaret: Boolean read GetHasCaret write SetHasCaret;
|
||||
@ -115,6 +116,8 @@ type
|
||||
|
||||
LCLViewExtension = objccategory(NSView)
|
||||
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;
|
||||
procedure lclSetVisible(AVisible: Boolean); message 'lclSetVisible:'; reintroduce;
|
||||
@ -2976,7 +2979,8 @@ end;
|
||||
|
||||
procedure LCLControlExtension.lclSetEnabled(AEnabled:Boolean);
|
||||
begin
|
||||
SetEnabled(AEnabled);
|
||||
SetEnabled(AEnabled and ((not Assigned(superview)) or (superview.lclisEnabled)) );
|
||||
inherited lclSetEnabled(AEnabled);
|
||||
end;
|
||||
|
||||
function LCLViewExtension.lclInitWithCreateParams(const AParams: TCreateParams): id;
|
||||
@ -3024,6 +3028,28 @@ begin
|
||||
SetViewDefaults(Result);
|
||||
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;
|
||||
begin
|
||||
Result := not isHidden;
|
||||
|
@ -34,6 +34,7 @@ type
|
||||
procedure SetHasCaret(AValue: Boolean);
|
||||
function GetIsOpaque: Boolean;
|
||||
procedure SetIsOpaque(AValue: Boolean);
|
||||
function GetShouldBeEnabled: Boolean;
|
||||
protected
|
||||
FTarget: TWinControl;
|
||||
class function CocoaModifiersToKeyState(AModifiers: NSUInteger): PtrInt; static;
|
||||
@ -1222,6 +1223,11 @@ begin
|
||||
FIsOpaque:=AValue;
|
||||
end;
|
||||
|
||||
function TLCLCommonCallback.GetShouldBeEnabled: Boolean;
|
||||
begin
|
||||
Result := Assigned(FTarget) and FTarget.Enabled;
|
||||
end;
|
||||
|
||||
{ TCocoaWSWinControl }
|
||||
|
||||
class procedure TCocoaWSWinControl.ArrangeTabOrder(
|
||||
|
Loading…
Reference in New Issue
Block a user