Object like Dialog but more like Javascript's Confirm box?

Duffield's icon

The topic says it all. I'm looking to have something like a confirm() function in Javascript (i.e., a prompt with the options "Ok" or "Cancel.)"

The [dialog] object is similar, but the user has to type in a message (much like the Javascript prompt() function). I'm looking for just a window with a "Ok" "Cancel" options that can be used to trigger a message.

Jan M's icon

AFAIK there us no such object. But you can constract it as a subpatcher/abstraction. That what i did in the past.

Nikolas K's icon

Like Jan said, do an abstraction, and send the "front" message to the abstraction's [thispatcher] whenever you want to prompt the user.

For a modal behavior imitation, what I did is, with scripting, make a panel covering the whole "back" window, on top of everything, with "ingoreclick" set to 0 so any click would be caught from the panel and do nothing!
You could also have a low opacity with a color on the panel (I use black) for a dimmed windows effect...

Duffield's icon

Thanks guys for the suggestions. I had a feeling it would come down to something like that, I just wanted to ensure I wasn't overlooking something simpler before putting in all the work.

Nikolas K's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I hope this helps,

Nik

mattyo's icon

You can get a Max system dialog with the shell object. This did not originate with me, someone else posted the basic script on the list. this example is OK only, but I'll bet you can work it out from here, most likely.

Max Patch
Copy patch and select New From Clipboard in Max.

\M

Duffield's icon

Very generous guys!

I really like @Nikolas's approach as I try not to use externals as much as possible.

Thanks!

Nikolas K's icon

I also try to avoid 3rd party externals, and usually want fully customizable GUIs. I sometimes spend more time designing my interfaces than the stuff under the hood!
So have fun with it!

Nik

jonah's icon

a hidden embedded b.patcher, set to open in presentation mode, arranged in front of everything else can work. inside something like a read only textedit set to click mode "output word" back into js and/or a 'cancel' button that sends a bang to hide it again...you can keep adding hidden bpatchers that you open from within even.

the other thing is, dialog bangs 1 out when it's been canceled another when okayed even with with nothing in it. or you can give it a label and default text. you couldn't stop someone from changing that text or maybe getting confused and thinking they needed to enter text, but....

this will toggle your bpatcher.
var i=1;
function bang ()
{
this.patcher.message( "script", "sendbox", "name_your_bpatcher", "hidden", i^=1 );
}

Philippe Montemont's icon

Hello All,
I have been using [dialog] for a very long time in my apps, due to the fact it was at the time possible to resize the user interface, with Resorcerer in my case. Max 4 times... Do you have an idea if this remains possible today, and how?
Best regards,
-Philippe

PS: As attachments, [dialog] in Max 7 and the modified Max 4 old one...
-P

Dialog-Max46.png
png
Dialog-Max7.png
png
Nikolas K's icon

Hi Philippe,

I am not aware of any "official", or not, way to alter the Max dialog box.
But I prefer the fully custom one, as it can be fully customizable, not only size or text...

Nik

hz37's icon

If you want to avoid [shell], you can use [jit.gl.lua] which lets you execute AppleScript:

function confirm()
    local f = io.popen("osascript -e 'tell app \"System Events\" to display dialog \"Are you sure?\" buttons {\"Yes\", \"Not really\"} with icon 0'")
    local l = f:read("*a") -- read output of command
    print(l)
    f:close()
end

Francois Weber's icon