From 7e8f2b7fdbf0e99a1efea3504791e1c11df05edc Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Tue, 27 Feb 2024 15:17:48 +0100 Subject: [PATCH] only disable group contents when property group is disabled --- haxe/ui/backend/ComponentBase.hx | 2 +- .../ui/containers/properties/PropertyGroup.hx | 33 +++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/haxe/ui/backend/ComponentBase.hx b/haxe/ui/backend/ComponentBase.hx index bfcff8ef5..7c5569982 100644 --- a/haxe/ui/backend/ComponentBase.hx +++ b/haxe/ui/backend/ComponentBase.hx @@ -6,8 +6,8 @@ import haxe.ui.behaviours.DataBehaviour; import haxe.ui.behaviours.DefaultBehaviour; import haxe.ui.behaviours.ValueBehaviour; import haxe.ui.core.Component; -import haxe.ui.core.IComponentContainer; import haxe.ui.core.IClonable; +import haxe.ui.core.IComponentContainer; import haxe.ui.core.IEventDispatcher; import haxe.ui.core.ImageDisplay; import haxe.ui.core.Screen; diff --git a/haxe/ui/containers/properties/PropertyGroup.hx b/haxe/ui/containers/properties/PropertyGroup.hx index feb294f2d..2915f999c 100644 --- a/haxe/ui/containers/properties/PropertyGroup.hx +++ b/haxe/ui/containers/properties/PropertyGroup.hx @@ -1,6 +1,7 @@ package haxe.ui.containers.properties; import haxe.ui.behaviours.DataBehaviour; +import haxe.ui.behaviours.DefaultBehaviour; import haxe.ui.components.Button; import haxe.ui.components.CheckBox; import haxe.ui.components.DropDown; @@ -14,10 +15,12 @@ import haxe.ui.core.CompositeBuilder; import haxe.ui.core.InteractiveComponent; import haxe.ui.events.MouseEvent; import haxe.ui.events.UIEvent; +import haxe.ui.util.Variant; @:composite(Events, Builder) class PropertyGroup extends VBox { - @:clonable @:behaviour(TextBehaviour) public var text:String; + @:clonable @:behaviour(TextBehaviour) public var text:String; + @:clonable @:behaviour(DisabledBehaviour) public var disabled:Bool; } //*********************************************************************************************************** @@ -31,6 +34,29 @@ private class TextBehaviour extends DataBehaviour { } } +@:dox(hide) @:noCompletion +@:access(haxe.ui.core.Component) +private class DisabledBehaviour extends DefaultBehaviour { + public override function set(value:Variant) { + var contents = _component.findComponent("property-group-contents", Component); + if (contents != null) { + contents.disabled = value; + } + var label:Label = _component.findComponent("property-group-header-label"); + if (label != null) { + label.disabled = value; + } + } + + public override function get():Variant { + var contents = _component.findComponent("property-group-contents", Component); + if (contents != null) { + return contents.disabled; + } + return false; + } +} + //*********************************************************************************************************** // Events //*********************************************************************************************************** @@ -152,11 +178,12 @@ private class Builder extends CompositeBuilder { var label = new Label(); label.scriptAccess = false; label.text = prop.label; - label.disabled = prop.disabled; label.addClass("property-group-item-label"); labelContainer.addComponent(label); labelContainer.hidden = prop.hidden; - labelContainer.disabled = prop.disabled; + if (prop.disabled) { + labelContainer.disabled = prop.disabled; + } cast(prop._compositeBuilder, PropertyBuilder).label = label; var editorContainer = new Box();