add input popup
This commit is contained in:
@@ -794,9 +794,12 @@ export class GameScene extends ResizableScene implements CenterListener {
|
||||
return;
|
||||
}
|
||||
const escapedMessage = HtmlUtils.escapeHtml(openPopupEvent.message);
|
||||
let html = `<div id="container" hidden><div class="nes-container with-title is-centered">
|
||||
${escapedMessage}
|
||||
</div> `;
|
||||
let html = `<div id="container" hidden><div class="nes-container with-title is-centered">`;
|
||||
html += escapedMessage;
|
||||
if (openPopupEvent.input) {
|
||||
html += `<input id="popupinput-${openPopupEvent.popupId}" class="nes-input" \>`
|
||||
}
|
||||
html += `</div> `;
|
||||
const buttonContainer = `<div class="buttonContainer"</div>`;
|
||||
html += buttonContainer;
|
||||
let id = 0;
|
||||
@@ -818,12 +821,15 @@ ${escapedMessage}
|
||||
}, 100);
|
||||
|
||||
id = 0;
|
||||
let inputElement : HTMLInputElement;
|
||||
if (openPopupEvent.input) {
|
||||
inputElement = HtmlUtils.getElementByIdOrFail<HTMLInputElement>(`popupinput-${openPopupEvent.popupId}`);
|
||||
}
|
||||
for (const button of openPopupEvent.buttons) {
|
||||
const button = HtmlUtils.getElementByIdOrFail<HTMLButtonElement>(`popup-${openPopupEvent.popupId}-${id}`);
|
||||
const btnId = id;
|
||||
button.onclick = () => {
|
||||
iframeListener.sendButtonClickedEvent(openPopupEvent.popupId, btnId);
|
||||
button.disabled = true;
|
||||
iframeListener.sendButtonClickedEvent(openPopupEvent.popupId, btnId, openPopupEvent.input, openPopupEvent.input ? inputElement.value : '');
|
||||
}
|
||||
id++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user