I have built a webpage using the Svelte framework. I want to be able to use the application both as a webpage, and as a desktop app on both Windows and Mac. To achieve this, I build it as a Tauri app.
Everything is working well. The webpage looks good on both Windows and Mac, and the desktop application is working for both as well.
To keep it simple, I run a function which in turn opens the prompt() function to add names or rename files. This is where I am now encountering a problem.
On the web and Windows version, everything works well. The prompt appears, I enter the name, and I click OK. The name is then updated.
However, on Mac, the prompt does not appear, and I get an error because the new name field is empty, and the rest of the function keeps running.
Is there any way to use prompt() in a Tauri app on Mac, or do I have to build my own sort of prompt?
To recreate it, add a button that runs a function including the prompt(). Build it as a Tauri app on Mac, run it, and click the button.
<button on:click={() => prompt()}></button>
The prompt will appear on a Windows version, however, it will not appear on Mac.
There are already more native versions of
alert
andconfirm
in@tauri-apps/api/dialog
butprompt
is currently missing.Your best bet is probably to implement your own (using Promises with
async
/await
as regular user interaction cannot be blocking likewindow.prompt
).