neon_crisp / Modules / utils/guiPopupManager / PopupParent
Class: PopupParent
utils/guiPopupManager.PopupParent
The PopupParent class manages communication between a popup parent and its child,
including handling input focus and sending open/close messages. This class facilitates
opening and closing popups, along with an optional callback mechanism for executing
specific actions when a popup is opened or closed.
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new PopupParent(childUrl, handleFocus?): PopupParent
Creates a new PopupParent instance.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
childUrl | url | undefined | The URL of the popup child. |
handleFocus? | boolean | true | Specifies whether input focus should be handled automatically. |
Returns
Defined in
Properties
childUrl
• childUrl: url
Defined in
handleFocus
• handleFocus: boolean
Defined in
openAndCloseCB
• Optional openAndCloseCB: (opening: boolean, message?: Record<string, any>) => void
Optional callback function that gets triggered when the popup is opened or closed.
This function receives two parameters: a boolean opening that indicates if the
popup is opening (true) or closing (false), and an optional message object.
Type declaration
▸ (opening, message?): void
Optional callback function that gets triggered when the popup is opened or closed.
This function receives two parameters: a boolean opening that indicates if the
popup is opening (true) or closing (false), and an optional message object.
Parameters
| Name | Type |
|---|---|
opening | boolean |
message? | Record<string, any> |
Returns
void
Defined in
Methods
close
▸ close(message): void
Closes the popup and posts a 'close' message to the child. If handleFocus is true,
the parent acquires input focus after closing the child.
Parameters
| Name | Type | Description |
|---|---|---|
message | Record<string, any> | The message to send when closing the popup. |
Returns
void
Defined in
onClose
▸ onClose(message): void
Parameters
| Name | Type |
|---|---|
message | Record<string, any> |
Returns
void
Defined in
on_message
▸ on_message(message_id, message, sender): void
Handles incoming messages from the child. Closes the popup if a 'close' message is received.
Parameters
| Name | Type | Description |
|---|---|---|
message_id | hash | The identifier of the received message. |
message | Record<string, any> | The message data. |
sender | url | The URL of the sender. |
Returns
void
Example
this.popupManager = new PopupParent("/popup#popup")
export function on_message(this: props, message_id: hash, message: Record<string, any>, sender: url): void {
this.popupManager.on_message(message_id, message, sender)
}
Defined in
open
▸ open(message, openStyle): void
Opens the popup and posts an 'open' message to the child. If handleFocus is true,
the parent releases input focus before opening the child.
Parameters
| Name | Type | Description |
|---|---|---|
message | Record<string, any> | The message to send when opening the popup. |
openStyle | OpenStyle | The style in which the popup should be opened. |
Returns
void
Defined in
setOpenAndCloseCB
▸ setOpenAndCloseCB(cb): void
Sets the callback function to be triggered when the popup is opened or closed.
Parameters
| Name | Type | Description |
|---|---|---|
cb | (opening: boolean, message?: Record<string, any>) => void | The callback function to be invoked. |
Returns
void