From f2cfc34aaf4fed7f95b8af00aad828efee5a578b Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 14 May 2024 17:47:24 +0800 Subject: [PATCH] bugfix --- bricks/tree.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/bricks/tree.js b/bricks/tree.js index b916aae..9f5f8ec 100755 --- a/bricks/tree.js +++ b/bricks/tree.js @@ -166,6 +166,20 @@ bricks.Tree = class extends bricks.VScrollPanel { this.create_node_children(this, this.opts.data); } create_toolbar(){ + var toolbar = bricks.extend({}, this.toolbar); + var tools = []; + toolbar.tools.forEach(f => tools.push(f)); + if (this.editable){ + tools.push({icon:bricks_resource('imgs/add.png'), name:'add'}); + tools.push({icon:bricks_resource('imgs/update.png'), name:'update'}); + tools.push({icon:bricks_resource('imgs/delete.png'), name:'delete'}); + } + toolbar.tools = tools; + this.toolbar_w = new bricks.IconBar(toolbar); + this.add_widget(this.toolbar_w); + this.toolbar_w.bind('add', this.add_new_node.bind(this)); + this.toolbar_w.bind('delete', this.delete.bind(this)); + this.toolbar_w.bind('update', this.update_node.bind(this)); } async get_children_data(node){ var jcall = bricks.jcall; @@ -186,15 +200,22 @@ bricks.Tree = class extends bricks.VScrollPanel { } } node_click_handle(node, event){ - if (this.selected_node){ + if (this.selected_node == node){ this.selected_node.selected(false); + this.selected_node = node; + } else { + if (this.selected_node){ + this.selected_node.selected(false); + } + this.selected_node = node; + node.selected(true); + this.dispatch('node_selected', node); } - this.selected_node = node; - node.selected(true); - this.dispatch('node_click', node); } } - +/* +在数控件中提供增删改能力 +*/ bricks. EditableTree = class extends bricks.Tree { /* {