Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to create a default button in a dialog window

Featured Replies

I have a dialog window with buttons. I open the window in a script, and when I click on any button a script runs with a single parameter containing text identifying which button was clicked. The button is set up to resume the original calling script. On resuming, the calling script closes the dialog window and acts on the text message, which is stored in a global field called message. My question is, how can one in effect create a default button? I want carriage return to cause the appropriate message to be added to the message field and then resume the calling script. Typing carriage return should be equivalent to clicking the default button. The layout trigger OnLayoutKeystroke can certainly invoke a script that will set the global message field to the default, but the trigger doesn't allow one to resume the calling script.

Is there a simple way to accomplish what I'm after?

are you using the "show custom dialog" script step or have you built your own dialog?

If the latter, you could make your new window modal and let the original script stop after spawning the window.  The scripts triggered by the user action or the layoutkeystroke for enter can just run the script it needs instead of trying to resume the paused script.

If your main script is paused, than hitting Return will resume it. You just need to populate the global field with the default value in the main script itself, and make the default button do Resume Script (without performing the subscript).

 

Edited by comment

  • Author

Thanks, both. Yes, I am talking about creating my own dialog. Wim, I can see how your solution will do the job. I assume this does mean, then, that if one wants to make a general practice of allowing users in each window with button choices to always have one default action and to be able to close the window using escape, one ends up with a profusion of scripts, many of them left hanging. So I take it that such a general practice would not be considered a best practice? I think I would generally stick with the convention of using dialog boxes for simple dialogs and have users rely solely on buttons for taking actions.

Consultant, when you say that hitting return will resume the main script if it's paused, are you talking about the case of "show custom dialog"?

 

13 minutes ago, jjjjp said:

 I assume this does mean, then, that if one wants to make a general practice of allowing users in each window with button choices to always have one default action and to be able to close the window using escape, one ends up with a profusion of scripts, many of them left hanging. So I take it that such a general practice would not be considered a best practice?

I don't really follow how you come to this conclusion about the profusion of scripts.  There is no best practice around showing dialogs; it's all fairly straightforward coding.

 

23 minutes ago, jjjjp said:

Consultant, when you say that hitting return will resume the main script if it's paused, are you talking about the case of "show custom dialog"?

No. I am talking about resuming your "original calling script", which is paused:

On 08/07/2016 at 11:11 PM, jjjjp said:

The button is set up to resume the original calling script. On resuming, the calling script closes the dialog window and acts on the text message, which is stored in a global field called message.

Even with your current arrangement, if the user does not click any of the buttons in the dialog window but presses Return or Enter instead, the original script resumes, does it not?

 

  • Author

Yes, you are right, Consultant. I see now that hitting return does resume the script, so populating the global variable with the default will work, whether or not the window is modal.

But I guess I don't understand what you are suggesting Wim, or at least how I can keep from adding a new script every time I want a dialog box. You yourself speak of spawning a new script. Maybe I'm missing something obvious.

I've created a simple script (attached) that has three buttons, one a default and one cancel. Clicking on a button saves a message to a global variable and then displays it. Clicking return does print the message corresponding to the default button. There is an enclosing loop. The loop exits when the user clicks on the cancel button. Start by clicking Test Dialog. Can you say how I can implement this so that clicking the escape key gets you out of the loop just as clicking the cancel button does?

TestDialog.fmp12.zip

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.