diff --git a/haxe/ui/components/Image.hx b/haxe/ui/components/Image.hx index d3d8fa616..938d2d75a 100644 --- a/haxe/ui/components/Image.hx +++ b/haxe/ui/components/Image.hx @@ -264,8 +264,10 @@ private class ResourceBehaviour extends DataBehaviour { _component.invalidateComponent(); return; } + var subImage = null; + + if(_component != null && _component.findComponent(Image) != null) subImage = _component.findComponent(Image); - var subImage = _component.findComponent(Image); if (subImage != null) { _component.removeComponent(subImage, false, false); } diff --git a/haxe/ui/containers/TreeView.hx b/haxe/ui/containers/TreeView.hx index 73144ab1d..ce77b181d 100644 --- a/haxe/ui/containers/TreeView.hx +++ b/haxe/ui/containers/TreeView.hx @@ -23,6 +23,8 @@ import haxe.ui.data.ArrayDataSource; import haxe.ui.data.DataSource; import haxe.ui.events.UIEvent; import haxe.ui.util.Variant; +import haxe.ui.events.EventType; + @:access(haxe.ui.containers.TreeViewNode) @:composite(TreeViewEvents, TreeViewBuilder) @@ -34,6 +36,8 @@ class TreeView extends ScrollView implements IDataComponent { @:call(ClearNodes) public function clearNodes():Void; @:call(GetNodesInternal) private function getNodesInternal():Array; + @:event(TreeViewEvent.NODE_COLLAPSE_EXPAND) public var onCollapseExpand:TreeViewEvent->Void; + private var _dataSource:DataSource = null; public var dataSource(get, set):DataSource; private function get_dataSource():DataSource { @@ -238,7 +242,28 @@ private class TreeViewBuilder extends ScrollViewBuilder { } } +class TreeViewEvent extends UIEvent{ + public static final NODE_COLLAPSE_EXPAND:EventType = EventType.name("nodecollapseexpand"); + public var expand:Bool = false; + public var affected_node:TreeViewNode; + public function new(type:EventType, expand:Bool = false, bubble:Null = false, data:Dynamic = null){ + super(type, bubble, data); + this.expand = expand; + } + public override function clone():TreeViewEvent { + var c:TreeViewEvent = new TreeViewEvent(this.type); + c.expand = this.expand; + c.affected_node = this.affected_node; + c.type = this.type; + c.bubble = this.bubble; + c.target = this.target; + c.data = this.data; + c.canceled = this.canceled; + postClone(c); + return c; + } +} /*************************************************************************************************** diff --git a/haxe/ui/containers/TreeViewNode.hx b/haxe/ui/containers/TreeViewNode.hx index 44771ea00..39c843028 100644 --- a/haxe/ui/containers/TreeViewNode.hx +++ b/haxe/ui/containers/TreeViewNode.hx @@ -12,6 +12,7 @@ import haxe.ui.core.InteractiveComponent; import haxe.ui.core.ItemRenderer; import haxe.ui.events.MouseEvent; import haxe.ui.util.Variant; +import haxe.ui.containers.TreeView.TreeViewEvent; #if (haxe_ver >= 4.2) import Std.isOfType; @@ -294,8 +295,13 @@ private class TreeViewNodeBuilder extends CompositeBuilder { private function onExpandCollapseClicked(event:MouseEvent) { event.cancel(); + var treeview = _node.findAncestor(TreeView); _node.expanded = !_node.expanded; updateIconClass(); + var event = new TreeViewEvent(TreeViewEvent.NODE_COLLAPSE_EXPAND); + event.expand = _node.expanded; + event.affected_node = _node; + treeview.dispatch(event); } public function updateIconClass() {