feat(popup-window): add onClickOutside prop

this method replaces close-on-click-outside behavior for the one defined
This commit is contained in:
retrozinndev
2025-05-21 14:53:43 -03:00
parent 3ee50a2f97
commit 7fff7817e1
+6
View File
@@ -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);
} }
} }
}, },