This commit is contained in:
yumoqing 2025-10-16 22:40:05 +08:00
parent 7bb133a027
commit f4c02569ac

View File

@ -25,8 +25,10 @@ bricks.IconBar = class extends bricks.HBox {
} }
super(opts); super(opts);
this.set_css('childrensize'); this.set_css('childrensize');
this.select_name = null;
this.height_int = 0; this.height_int = 0;
var tools = this.opts.tools; var tools = this.opts.tools;
this.toolws = {};
for (var i=0;i<tools.length;i++){ for (var i=0;i<tools.length;i++){
var opts_i = bricks.extend({}, tools[i]); var opts_i = bricks.extend({}, tools[i]);
if (!opts_i.rate){ if (!opts_i.rate){
@ -43,6 +45,7 @@ bricks.IconBar = class extends bricks.HBox {
} }
w.set_style('cursor', 'pointer'); w.set_style('cursor', 'pointer');
this.add_widget(w); this.add_widget(w);
this.toolws[tools[i].name] = w;
} }
this.set_style('alignItems', 'center'); this.set_style('alignItems', 'center');
// this.set_style('justifyContent', 'center'); // this.set_style('justifyContent', 'center');
@ -67,8 +70,14 @@ bricks.IconBar = class extends bricks.HBox {
return w; return w;
} }
regen_event(desc, event){ regen_event(desc, event){
if (this.selected_name){
this.toolws[this.selected_name].set_css('selected', true);
}
this.selected_name = desc.name;
this.dispatch(desc.name, desc); this.dispatch(desc.name, desc);
this.dispatch('command', desc); this.dispatch('command', desc);
this.toolws[this.selected_name].set_css('selected');
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }