✨ feat(popup-window): add onClickOutside prop
this method replaces close-on-click-outside behavior for the one defined
This commit is contained in:
@@ -8,6 +8,7 @@ type PopupWindowSpecificProps = {
|
|||||||
onButtonPressEvent?: (self: Gtk.Widget, event: Gdk.Event) => void;
|
onButtonPressEvent?: (self: Gtk.Widget, event: Gdk.Event) => void;
|
||||||
/** Stylesheet for the background of the popup-window */
|
/** Stylesheet for the background of the popup-window */
|
||||||
cssBackgroundWindow?: string;
|
cssBackgroundWindow?: string;
|
||||||
|
onClickedOutside?: (self: Widget.Window) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PopupWindowProps = Pick<Widget.WindowProps,
|
export type PopupWindowProps = Pick<Widget.WindowProps,
|
||||||
@@ -75,7 +76,12 @@ export function PopupWindow(props: PopupWindowProps): Widget.Window {
|
|||||||
if((x < allocation.x || x > (allocation.x + allocation.width)) ||
|
if((x < allocation.x || x > (allocation.x + allocation.width)) ||
|
||||||
(y < allocation.y || y > (allocation.y + allocation.height))) {
|
(y < allocation.y || y > (allocation.y + allocation.height))) {
|
||||||
|
|
||||||
|
if(!props.onClickedOutside) {
|
||||||
self.close();
|
self.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
props.onClickedOutside?.(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user