Creating a Web Message Box la Desktop

Hi,

as probably many of you, I find the Web MsgBox a bit (lot ?) short compared to the Desktop version. I would like to create my own version of this Message Box. Creating the WebDialog, but then how can you implement it so it would looks like a function call returning the name of the button that was pressed:

Res = MyMsgBox(title as String, message as String, b1 as string, b2 as string) as Integer for example ?

I googled on this but couldn’t find anything. My guess is that I am not the first one looking for this. I would like to make it so I can reuse this in different projects.

Many hanks

You can’t customize the labels on a Javascript alert();, confirm();, or prompt(); dialog. You can use WebControlWrapper to write your own custom control that will return to you the value of a confirm or prompt dialog, but there is nothing built in to the Web Framework to do so.

Please note: These dialogs are not modal. I do not recall if the Web framework MsgBox pauses execution, but if it does - that’s the Xojo framework doing it, not Javascript.

@Tim Parnell

Hum, I don’t think that a WebDialog will call any of these Javascript functions. Then how can I get the name of a button pressed inside a WebDialog and return it ?

Well now you’re talking about different things. WebDialog is different from the Web Framework MsgBox function. If you’re creating a WebDialog, you can create the design to be anything you want, but looking at the documentation, there is no ShowModal so you won’t be able to pause execution.

You may wish to read up on the documentation for WebDialog to understand it a little bit more. You may find the “Differences Between Dialogs in Web and Desktop Applications” section of particular interest.
http://documentation.xojo.com/index.php/WebDialog

@Tim Parnell

A webDialog can be Modal by setting the Type property to Modal (from the link you provided). The entire app is blocked the, So how can I create a function that will take parameters to set the title, the message, the buttons text, etc. and return which button was pressed ?

With WebDialogs I think “modal” only refers to the design / overlay aspect because the documentation states “Keep in mind that dialogs are not modal and do not stop your code from running.”

You may need to adjust your design concept as I don’t think you’ll be able to execute your code in a procedural style.

From the Language Reference:

With a Desktop application, the current method stops executing.

In a Web app, it’s modal in that you have to deal with the Web Dialog, you can’t trigger other objects events. To achieve the desired result, looks like I would need to set at run time the handler for my buttons.

If you want to see how I do it have a look at this project

Hi Wayne,

I will try that, but with a Modal WebDialog. I am pretty sure it will do it.

Thanks

I found GraffitiSuite a couple of years ago. It has an alert popup that is pretty flexible.

It is a paid product and you get lots of other controls. They have separate Web and Desktop versions.

Just a alternative if you have some budget money. They have an on-line demo.