How to make an input dialog box?

something like this


but i dont want a multiline input.
i need to return the input of the dialig box, and be able to customize the title with a custom block
(open dialog box[title]default value[default]and wait

I think the SciSnap library has stuff in it to do things like this - worth having a look

It only offers a rudimentary dialog box with an OK button.

I wish, without not only learning JS, but also learning the behind-the-scenes of Snap!. It would come in handy to replicate the message menu for a new class.


could have answered your question, assuming that you are okay with JS, but it does not offer a dialog with a single-line text box, only one with multiple lines.

thanks helicoptur for this though, but they are inactive

im okay with javascript, i just need a single line textbox.

This will get you the idea.

new DialogBoxMorph(target, action, environment).prompt(title, defaultString, world);

This is good for displaying the dialog boxes, but how do you actually get the value of the box?

Yeah, this is what I sucked at. I would have shared the finished product if it didn’t raise this question.

This line simply presents the dialog box then moves on without waiting for the user. It will only call action once the dialog has been closed.

If I declare a variable then return it right after the dialog has been created, the function will report nothing.

bump, i need some help here.

What is your use case? Particularly easy is the following: a makeshift “new…” option in a dropdown that is similar to the one in broadcast (), where clicking the “new…” option summons a dialog to input a different name not listed.

There is na old experiment - value from async JS
custom dialog script pic (1)

Just remove the resizing handle and it is perfect!

i just had to remove a single line of code to remove the handle :slight_smile:

Sometimes, i never get the result… get stuck in the repeat until…

That happens to me when I use the enter key to exit the dialogue instead of clicking OKAY.

Ohhh, I see… I look at this later.

Now
Enter, ( OK ) works as accept
Esc, ( Cancel ) as cancel

untitled script pic (87)

Two lines. The extraneous fixLayout().

I’m going to be so honest right now. I have quite a bit of experience with modding Snap! and Morphic.js in general. I have no idea how to make a single line dialog box. I made a userscript a while ago that allows you to change the speed of which variable monitors update, and I spent around a half hour trying to figure out how to make the input just a singular line, only to compromise with having a multi-line input where a single line should be. That was months ago, however, so I could probably improve upon it if I wanted to.