Jump 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.

Featured Replies

I am trying to accelerate my learning by looking at extending some of the examples as well as writing my own

After doing some swingbuilder learning today I wanted to make sure I could capture the returns from the dialog.

I have amended it so that it will take multiple button values in a list

as:

// DynamicMessage ( fm_Title, fm_Message, fm_Buttons

// creates a dialog with html body and buttons from a return sep list

//  captures exit values as false and ESC is -1 (int)



import groovy.swing.SwingBuilder



swing = new SwingBuilder()

buttons = fm_Buttons.split('n')

def dialog = swing.optionPane(

  message:fm_Message, options:(buttons)

)

dialog.createDialog(null, fm_Title).show()

if ( dialog.getValue() == null) {

	return false

}

return dialog.getValue()

BUT if you close the dialog with no choice it returns null, if you dismiss by ESCAPING it returns -1 as an integer and in all other cases it returns the string value of the button

if you try and do Integer.toString(dialog.getValue() to test if it is a literal "-1" then of course it fails when the response is a button string.

Anyone any ideas how to achieve this??

I am just trying to capture how a user leaves the dialog box in more detail...

Edited by Guest

  • Author

Just updated so the button number rather than the value is returned

Only problem is still with the ESC key causing an error to be thrown at is is an not string

// DynamicMessage ( fm_Title, fm_Message, fm_Buttons

// creates a dialog with html body and buttons from a list, captures exit values as false and ESC is -1 (int)

// amended version which captures button pressed as numeric value so can be

// used like FM Get(LastMessage Choice)

/// still needs ESC value sorting - throws error



import groovy.swing.SwingBuilder



swing = new SwingBuilder()

buttons = fm_Buttons.split('n')

test = buttons.join(",")

zerobut = buttons.size() - 1

int bnum = 0

int i = 0

test = ""

def dialog = swing.optionPane(

  message:fm_Message, options:(buttons)

)

dialog.createDialog(null, fm_Title).show()

if ( dialog.getValue() == null) {

	return false

}

buttons.each(){

	i = i + 1

	if ( it == dialog.getValue()){

	bnum = i

	} else {

	bnum = bnum

	}

}

if (bnum > 0) {

	return bnum

}

return "ERROR"

// at the moment

Create an account or sign in to comment

Important Information

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

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.