February 18, 200916 yr 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.
February 18, 200916 yr 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: 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" ); }
February 25, 200916 yr 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