This commit is contained in:
yumoqing 2025-12-26 10:44:23 +08:00
parent 8a9bc2cdbb
commit e29bd44137
2 changed files with 10 additions and 3 deletions

View File

@ -240,19 +240,21 @@ bricks.universal_handler = async function(from_widget, widget, desc, event){
bricks.default_popup = function(opts){ bricks.default_popup = function(opts){
var popts = bricks.get_popup_default_options(); var popts = bricks.get_popup_default_options();
bricks.extend(popts, opts); bricks.extend(popts, opts);
popts.origin_event = event;
return new bricks.Popup(popts); return new bricks.Popup(popts);
} }
bricks.default_popupwindow = function(opts){ bricks.default_popupwindow = function(opts,event){
var popts = bricks.get_popupwindow_default_options(); var popts = bricks.get_popupwindow_default_options();
bricks.extend(popts, opts); bricks.extend(popts, opts);
popts.origin_event = event;
return new bricks.PopupWindow(popts); return new bricks.PopupWindow(popts);
} }
bricks.buildEventHandler = async function(w, desc, event){ bricks.buildEventHandler = async function(w, desc, event){
var target; var target;
if (desc.target == 'Popup'){ if (desc.target == 'Popup'){
target = bricks.default_popup(desc.popup_options || {}); target = bricks.default_popup(desc.popup_options || {}, event);
} else if (desc.target == 'PopupWindow') { } else if (desc.target == 'PopupWindow') {
target = bricks.default_popupwindow(desc.popup_options || {}); target = bricks.default_popupwindow(desc.popup_options || {}, event);
} else if ( desc.target instanceof bricks.JsWidget ) { } else if ( desc.target instanceof bricks.JsWidget ) {
target = desc.target; target = desc.target;
} else { } else {

View File

@ -179,6 +179,11 @@ bricks.Popup = class extends bricks.VBox {
positify_tl(){ positify_tl(){
var rect, w, h, t, l; var rect, w, h, t, l;
if (self.opts.eventpos && self.opts.origin_event){
this.set_style('top', this.origin_event.offsetY + 'px');
this.set_style('left', this.origin_event.offsetX + 'px');
return;
}
if (this.top && this.left){ if (this.top && this.left){
this.set_style('top', this.top); this.set_style('top', this.top);
this.set_style('left', this.left); this.set_style('left', this.left);