Skip to content

Commit

Permalink
Adding appendChild fix for GWT game input, to see if it works in Safari.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanceewing committed Apr 7, 2024
1 parent 5eea774 commit 950b015
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions html/src/main/java/com/agifans/agile/gwt/GwtDialogHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,12 @@ private final native void showHtmlOpenFileDialog(String type, GwtOpenFileResults
console.log('Finished creating input element of type file');
document.body.appendChild(fileInputElem);
// The change event occurs after a file is chosen.
fileInputElem.addEventListener("change", function(event) {
document.body.removeChild(fileInputElem);
if (this.files.length === 0) {
console.log('No files selected for import');
Expand Down Expand Up @@ -319,6 +323,15 @@ private final native void showHtmlOpenFileDialog(String type, GwtOpenFileResults
}
});
fileInputElem.addEventListener("cancel", function(event) {
document.body.removeChild(fileInputElem);
console.log('Open file dialog was cancelled.');
// No file was selected, so nothing more to do.
[email protected]::onFileResultsReady([Lcom/agifans/agile/gwt/GwtOpenFileResult;)([]);
});
// Trigger the display of the open file dialog.
fileInputElem.click();
Expand Down

0 comments on commit 950b015

Please sign in to comment.