This commit is contained in:
yumoqing 2024-08-20 18:25:45 +08:00
parent bba72ea544
commit 576ca6b4b1

View File

@ -12,7 +12,7 @@ bricks.Menu = class extends bricks.VBox {
this.dom_element.style.display = ""; this.dom_element.style.display = "";
this.dom_element.style.backgroundColor = options.bgcolor || "white"; this.dom_element.style.backgroundColor = options.bgcolor || "white";
this.create_children(this, this.opts.items); this.create_children(this, this.opts.items);
this.bind('click', this.menu_clicked); this.bind('click', this.menu_clicked.bind(this));
} }
create_submenu_container(){ create_submenu_container(){
let cp = new bricks.VBox({}); let cp = new bricks.VBox({});
@ -22,11 +22,12 @@ bricks.Menu = class extends bricks.VBox {
} }
async menu_clicked(event){ async menu_clicked(event){
let e = event.target; let e = event.target;
var item = e.bricks_widget; let opts = event.params.opts;
console.log('menu_clicked(): item=', item, item.opts, item.url); var menu = e.bricks_widget;
if (!item.url){ console.log('menu_clicked(): item=', item, item.opts, opts);
if (! opts.url){
console.log('itme.url is null'); console.log('itme.url is null');
this.dispatch('command', item.opts); this.dispatch('command', opts);
return; return;
} }
var t = bricks.getWidgetById(this.target); var t = bricks.getWidgetById(this.target);
@ -34,7 +35,7 @@ bricks.Menu = class extends bricks.VBox {
var desc = { var desc = {
"widgettype":"urlwidget", "widgettype":"urlwidget",
"options":{ "options":{
"url":item.url "url":opts.url
} }
} }
var w = await bricks.widgetBuild(desc, this); var w = await bricks.widgetBuild(desc, this);
@ -97,7 +98,7 @@ bricks.Menu = class extends bricks.VBox {
} }
regen_menuitem_event(item, event){ regen_menuitem_event(item, event){
console.log('regen_menuitem_event()', item); console.log('regen_menuitem_event()', item);
item.dispatch('click', item); this.dispatch('click', item);
event.stopPropagation(); event.stopPropagation();
} }
} }