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.

Call a script after choice in a popup menu

Featured Replies

Hi,

I modified the script "Popup Menu" in the demofile to call a script, but it ignores this step. I extended the function in line 51 about an if-clause like this:

public void actionPerformed( ActionEvent e ) {

String menuText = ( (JMenuItem)e.getSource() ).getText();

//Here starts the if-clause

if (menuText == "Choice 1"){

// If you would like this to trigger a script, reeplace this with some call to a FileMaker script, like this:

//calling the script "Whatever"

fmpro.performScript("ScriptMaster", "Whatever");

} }

What's going wrong?

Reinhold.

If you look at your java console log, you'll likely see something like the following:

Exception in thread "AWT-EventQueue-0" groovy.lang.MissingPropertyException: No such property: fmpro for class: swing.PopupMenu

This is because the event handler is referencing the 'fmpro' from within the event handler, in which it's no longer defined. One fix is to set a static field to the FMPro object, before the class is launched. Add this code after the import statements:

:D

PopupMenu.fmpro = fmpro;

new PopupMenu().drawPopupMenu();



Add a field definition to the PopupMenu class to hold the fmpro



    
static Object fmpro;



Then in your action handler, reference this static field instead (be sure to call a script which exists in the file)
public void actionPerformed( ActionEvent e ) {

        String menuText = ( (JMenuItem)e.getSource() ).getText();

        PopupMenu.fmpro.performScript("ScriptMaster", "TOC" ); 

    }

  • Author

Thanks a lot!

It works, but I think, that I have to learn more about Java/Groovy. Because this script lacks the functions to generate the value list by calculation or relationsship. Or the possibility to assign a script to an item of the value list...

May be, that I find the time for programming this in the next weeks...

Reinhold

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.