Skip to content

Commit

Permalink
only disable group contents when property group is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Feb 27, 2024
1 parent f20976c commit 7e8f2b7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion haxe/ui/backend/ComponentBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
33 changes: 30 additions & 3 deletions haxe/ui/containers/properties/PropertyGroup.hx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}

//***********************************************************************************************************
Expand All @@ -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
//***********************************************************************************************************
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7e8f2b7

Please sign in to comment.