From 255890be322e942ae26a28ed704ede035c153e20 Mon Sep 17 00:00:00 2001 From: Hion-V Date: Sat, 24 Feb 2024 07:08:40 +0100 Subject: [PATCH 1/7] Implemented a TreeViewEvent --- haxe/ui/containers/TreeView.hx | 13 +++++++++++++ haxe/ui/containers/TreeViewNode.hx | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/haxe/ui/containers/TreeView.hx b/haxe/ui/containers/TreeView.hx index 73144ab1d..7b10cbf33 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,16 @@ 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 node:TreeViewNode; + public function new(type:EventType, expand:Bool = false, bubble:Null = false, data:Dynamic = null){ + super(type, bubble, data); + this.expand = expand; + } +} /*************************************************************************************************** diff --git a/haxe/ui/containers/TreeViewNode.hx b/haxe/ui/containers/TreeViewNode.hx index 44771ea00..0911442d4 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(); + trace("expandCollapseClicked"); + var event = new TreeViewEvent(TreeViewEvent.NODE_COLLAPSE_EXPAND); + event.expand = _node.expanded; + treeview.dispatch(event); } public function updateIconClass() { From 51a52a5380deb8e1710003a7082596a79c572a3e Mon Sep 17 00:00:00 2001 From: Hion-V Date: Sat, 24 Feb 2024 07:19:41 +0100 Subject: [PATCH 2/7] Fixed a Null Object Reference Error --- haxe/ui/components/Image.hx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } From a634d640a9069f4baec102e33ba4d92d88472663 Mon Sep 17 00:00:00 2001 From: Hion-V Date: Sat, 24 Feb 2024 07:21:53 +0100 Subject: [PATCH 3/7] Removed trace --- haxe/ui/containers/TreeViewNode.hx | 1 - 1 file changed, 1 deletion(-) diff --git a/haxe/ui/containers/TreeViewNode.hx b/haxe/ui/containers/TreeViewNode.hx index 0911442d4..b0e4fa4cb 100644 --- a/haxe/ui/containers/TreeViewNode.hx +++ b/haxe/ui/containers/TreeViewNode.hx @@ -298,7 +298,6 @@ private class TreeViewNodeBuilder extends CompositeBuilder { var treeview = _node.findAncestor(TreeView); _node.expanded = !_node.expanded; updateIconClass(); - trace("expandCollapseClicked"); var event = new TreeViewEvent(TreeViewEvent.NODE_COLLAPSE_EXPAND); event.expand = _node.expanded; treeview.dispatch(event); From 27203e8a63ff72efd98afc38e24b66195492cd6d Mon Sep 17 00:00:00 2001 From: Hion-V Date: Sat, 24 Feb 2024 07:33:40 +0100 Subject: [PATCH 4/7] changes to TreeViewEvent --- haxe/ui/containers/TreeView.hx | 2 +- haxe/ui/containers/TreeViewNode.hx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/haxe/ui/containers/TreeView.hx b/haxe/ui/containers/TreeView.hx index 7b10cbf33..05c0deafe 100644 --- a/haxe/ui/containers/TreeView.hx +++ b/haxe/ui/containers/TreeView.hx @@ -246,7 +246,7 @@ class TreeViewEvent extends UIEvent{ public static final NODE_COLLAPSE_EXPAND:EventType = EventType.name("nodecollapseexpand"); public var expand:Bool = false; - public var node:TreeViewNode; + 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; diff --git a/haxe/ui/containers/TreeViewNode.hx b/haxe/ui/containers/TreeViewNode.hx index b0e4fa4cb..39c843028 100644 --- a/haxe/ui/containers/TreeViewNode.hx +++ b/haxe/ui/containers/TreeViewNode.hx @@ -300,6 +300,7 @@ private class TreeViewNodeBuilder extends CompositeBuilder { updateIconClass(); var event = new TreeViewEvent(TreeViewEvent.NODE_COLLAPSE_EXPAND); event.expand = _node.expanded; + event.affected_node = _node; treeview.dispatch(event); } From c59d4cab4b3665738d5522621b1f33ce76922ed8 Mon Sep 17 00:00:00 2001 From: Hion-V Date: Sat, 24 Feb 2024 07:44:26 +0100 Subject: [PATCH 5/7] attempt to fix event being null --- haxe/ui/containers/TreeView.hx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/haxe/ui/containers/TreeView.hx b/haxe/ui/containers/TreeView.hx index 05c0deafe..6273a7641 100644 --- a/haxe/ui/containers/TreeView.hx +++ b/haxe/ui/containers/TreeView.hx @@ -251,6 +251,18 @@ class TreeViewEvent extends UIEvent{ super(type, bubble, data); this.expand = expand; } + public override function clone():MenuEvent { + var c:MenuEvent = new MenuEvent(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; + } } From f1a91fa22af8ac8e07e5444e8caa2e1c632851fb Mon Sep 17 00:00:00 2001 From: Hion-V Date: Sat, 24 Feb 2024 07:45:26 +0100 Subject: [PATCH 6/7] Fixed copypaste induced mistake --- haxe/ui/containers/TreeView.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haxe/ui/containers/TreeView.hx b/haxe/ui/containers/TreeView.hx index 6273a7641..194e6cdfc 100644 --- a/haxe/ui/containers/TreeView.hx +++ b/haxe/ui/containers/TreeView.hx @@ -251,8 +251,8 @@ class TreeViewEvent extends UIEvent{ super(type, bubble, data); this.expand = expand; } - public override function clone():MenuEvent { - var c:MenuEvent = new MenuEvent(this.type); + 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; From a33520ff04d3dd231b2adca75f374fb2d25ddf08 Mon Sep 17 00:00:00 2001 From: Hion-V Date: Sat, 24 Feb 2024 07:46:15 +0100 Subject: [PATCH 7/7] fixed typo --- haxe/ui/containers/TreeView.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haxe/ui/containers/TreeView.hx b/haxe/ui/containers/TreeView.hx index 194e6cdfc..ce77b181d 100644 --- a/haxe/ui/containers/TreeView.hx +++ b/haxe/ui/containers/TreeView.hx @@ -254,7 +254,7 @@ class TreeViewEvent extends UIEvent{ public override function clone():TreeViewEvent { var c:TreeViewEvent = new TreeViewEvent(this.type); c.expand = this.expand; - c.affected_Node = this.affected_node; + c.affected_node = this.affected_node; c.type = this.type; c.bubble = this.bubble; c.target = this.target;