Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5761 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

Posted

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" ); 

    }

Posted

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

This topic is 5761 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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