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

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

Recommended Posts

Posted

Hi,

Since SwingBuilder can handle menu's and ScriptMaker can handle calling FM scripts

is it possible to make a dropdown box at the cursor position, or at the position of a button

(or at a given position) with the script parameters to pass on to a script?

That way I can use one print button with a dropdown to select several options to print

like:

List with prices

List without prices

List internal

Best regards,

Ruben van den Boogaard

Infomatics Software

Posted

I am not sure that you could accomplish this with Scriptmaster... However, I have not really begun to push it's Groovy scripting limits...

That being said, you can accomplish what you want with a relationship and a portal with the list and each line a button. Any further look into this method would, of course, be best served in the Relationships Forum. :)

Posted

Hi,

Since SwingBuilder can handle menu's and ScriptMaker can handle calling FM scripts

Are you asking if you can build a dropdown in a Groovy application that calls a ScriptMaker script in FileMaker, based on the dropdown value selected by the user?

Or if you can generate a dropdown list within the FM application using SwingBuilder/Groovy, to control FM behavior?

If the latter, you might want to consider using FM's built in dropdown functionality, which, if you leave the cursor position requirement aside, is more than capable of handling the feature you want to build.

I'd love to see the results of what you're describing - it would be a very cool widget. And I have no real idea what's involved in building Java code or how it might integrate with other apps.

But my guess is, weighing the coding involved in creating a Java app to do something that 5 minutes of work using native FM tools can resolve (minus the cursor position)...

Well, seems like a lot of work, no?

Anyway, on the Mac platform FM is AppleScript aware, and on the PC ActiveX aware. You'd probably want to have your app figure out which FM file is frontmost, what table and layout it's open to, etc - and base your widget's dropdown values and script calls accordingly. I see loads of opportunities for breakage here.

Posted

Try this code. You'll need to customize it obviously, but I think it can do what you're looking for. I'm also attaching it, in case it gets mangled on the web.

The trick is to create a full-screen invisible, modal JDialog. Once you have that, you can draw anything you want onto it. I get the mouse position using MouseInfo.getPointerInfo().getLocation().

====


package swing;



import javax.swing.*;

import javax.swing.event.PopupMenuEvent;

import javax.swing.event.PopupMenuListener;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.ComponentListener;

import java.awt.event.ComponentEvent;

import java.lang.reflect.InvocationTargetException;



/**

 * Created by IntelliJ IDEA. User: jesse Date: Jan 7, 2008 Time: 8:31:33 AM

 */

public class PopupMenu implements ActionListener, PopupMenuListener, ComponentListener {

	/*If I set transparency to 0, then it doesn't detect background clicks to close the popup, so I set it to 7, which seems like the minimum threshold */

	private static final Color TRANSPARENT = new Color(255, 255, 255, 7 );

	public JDialog menuFrame;

	public JPopupMenu popup;



	private void drawPopupMenu() {

		menuFrame = new JDialog( (Frame)null, true );



		popup = new JPopupMenu( "Popup" );

		popup.addPopupMenuListener( this );

		JMenuItem choice1 = new JMenuItem( "Choice 1" );

		choice1.addActionListener( this );

		popup.add( choice1 );

		JMenuItem choice2 = new JMenuItem( "Choice 2" );

		choice2.addActionListener( this );

		popup.add( choice2 );

		JMenuItem choice3 = new JMenuItem( "Choice 3" );

		choice3.addActionListener( this );

		popup.add( choice3 );



		menuFrame.setUndecorated( true );

		menuFrame.setBackground( TRANSPARENT );

		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

		menuFrame.setBounds( 0, 0, (int)screenSize.getWidth(), (int)screenSize.getHeight() );

		menuFrame.addComponentListener( this );

		menuFrame.setVisible( true );

	}





	public static void main(String[] args) throws InterruptedException, InvocationTargetException {

		new PopupMenu().drawPopupMenu();

	}





	public void actionPerformed( ActionEvent e ) {

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

		/* Replace this with some call to a FileMaker script, like this:

		fmpro.performScript(fileName, scriptName, menuText ); */

		JOptionPane.showMessageDialog( null, "You picked " + menuText );

	}





	public void popupMenuWillBecomeVisible( PopupMenuEvent e ) {}

	public void popupMenuCanceled( PopupMenuEvent e ) {}



	public void popupMenuWillBecomeInvisible( PopupMenuEvent e ) {

		menuFrame.dispose(); /* Get rid of invisible window after making a selection */

	}



	public void componentResized( ComponentEvent e ) {}



	public void componentMoved( ComponentEvent e ) {}



	public void componentHidden( ComponentEvent e ) {}



	public void componentShown( ComponentEvent e ) {

		Point mouseLoc = MouseInfo.getPointerInfo().getLocation(); /* Absolute coordinates, need to convert to component coordinates */

		mouseLoc.x -= menuFrame.getX();

		mouseLoc.y -= menuFrame.getY();

		popup.show( menuFrame, (int)mouseLoc.x, (int)mouseLoc.y );

	}

}

Popup_menus.txt

  • 1 year later...
Posted

Has anyone been able to get this Groovy Script to call an FMpro script or return a result? I've been trying to re-write it so it can, but haven't had much success.

Thanks!

Posted

Searching for a solution to my issue and thinking ScriptMaster may help. I'm just not sure it's worth going through all the issues with the plug-in just to be able to do what I want.

Rather than completely reposting here (unless you want or a new thread), Topic Here is the thread I've been working on.

Thanks!!!!

Posted

Hey Angelo - here's a modified version. This takes an input parameter called 'choices' and returns the user's selection:


package swing;



import javax.swing.*;

import javax.swing.event.PopupMenuEvent;

import javax.swing.event.PopupMenuListener;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.ComponentListener;

import java.awt.event.ComponentEvent;

import java.lang.reflect.InvocationTargetException;



def popup = new PopupMenu();

popup.setChoices( choices.split("n") );

popup.drawPopupMenu();

return popup.getSelectedItem();



/**

 * Created by IntelliJ IDEA. User: jesse Date: Jan 7, 2008 Time: 8:31:33 AM

 */

public class PopupMenu implements ActionListener, PopupMenuListener, ComponentListener {

	/*If I set transparency to 0, then it doesn't detect background clicks to close the popup, so I set it to 7, which seems like the minimum threshold */

	private static final Color TRANSPARENT = new Color(255, 255, 255, 7 );

	private JDialog menuFrame;

	private JPopupMenu popup;

	private String selectedItem;

	private String[] choices;



	public static void main(String[] args) throws InterruptedException, InvocationTargetException {

		PopupMenu popup = new PopupMenu();

		String choices = "Choice 1nChoice 2nChoice 3";

		popup.setChoices( choices.split( "n" ) );

		popup.drawPopupMenu();

		System.out.println( "Selection: " + popup.getSelectedItem() );

	}



	public void setChoices( String[] choices ) {

		this.choices = choices;

	}



	public String getSelectedItem() {

		return selectedItem;

	}



	private void drawPopupMenu() {

		menuFrame = new JDialog( (Frame)null, true );



		popup = new JPopupMenu( "Popup" );

		popup.addPopupMenuListener( this );

		for( int n=0; n

  • 1 month later...
Posted (edited)

Hi Everyone,

The script above seems to have an error in it ("choices" should be defined before "popup.setChoices..." towards the beginning of the script). The code that worked for me is as follows:

package swing;



import javax.swing.*;

import javax.swing.event.PopupMenuEvent;

import javax.swing.event.PopupMenuListener;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.ComponentListener;

import java.awt.event.ComponentEvent;

import java.lang.reflect.InvocationTargetException;



def popup = new PopupMenu();

String choices = "Choice 1nChoice 2nChoice 3";

popup.setChoices( choices.split("n") );

popup.drawPopupMenu();

return popup.getSelectedItem();



/**

 * Created by IntelliJ IDEA. User: jesse Date: Jan 7, 2008 Time: 8:31:33 AM

 */

public class PopupMenu implements ActionListener, PopupMenuListener, ComponentListener {

	/*If I set transparency to 0, then it doesn't detect background clicks to close the popup, so I set it to 7, which seems like the minimum threshold */

	private static final Color TRANSPARENT = new Color(255, 255, 255, 7 );

	private JDialog menuFrame;

	private JPopupMenu popup;

	private String selectedItem;

	private String[] choices;



	public static void main(String[] args) throws InterruptedException, InvocationTargetException {

		PopupMenu popup = new PopupMenu();

		String choices = "Choice 1nChoice 2nChoice 3";

		popup.setChoices( choices.split( "n" ) );

		popup.drawPopupMenu();

		System.out.println( "Selection: " + popup.getSelectedItem() );

	}



	public void setChoices( String[] choices ) {

		this.choices = choices;

	}



	public String getSelectedItem() {

		return selectedItem;

	}



	private void drawPopupMenu() {

		menuFrame = new JDialog( (Frame)null, true );



		popup = new JPopupMenu( "Popup" );

		popup.addPopupMenuListener( this );

		for( int n=0; n

			JMenuItem choice = new JMenuItem( choices[n] );

			choice.addActionListener( this );

			popup.add( choice );

		}

		menuFrame.setUndecorated( true );

		menuFrame.setBackground( TRANSPARENT );

		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

		menuFrame.setBounds( 0, 0, (int)screenSize.getWidth(), (int)screenSize.getHeight() );

		menuFrame.addComponentListener( this );

		menuFrame.setVisible( true );

	}





	public void actionPerformed( ActionEvent e ) {

		selectedItem = ( (JMenuItem)e.getSource() ).getText();

		menuFrame.dispose(); /* Get rid of invisible window after making a selection */

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

		//fmpro.performScript(fileName, scriptName, menuText ); */

		//JOptionPane.showMessageDialog( null, "You picked " + selectedItem );

	}



	public void componentShown( ComponentEvent e ) {

		Point mouseLoc = MouseInfo.getPointerInfo().getLocation(); /* Absolute coordinates, need to convert to component coordinates */

		mouseLoc.x -= menuFrame.getX();

		mouseLoc.y -= menuFrame.getY();

		popup.show( menuFrame, (int)mouseLoc.x, (int)mouseLoc.y );

	}



	public void popupMenuWillBecomeInvisible( PopupMenuEvent e ) {}



	public void popupMenuWillBecomeVisible( PopupMenuEvent e ) {}



	public void popupMenuCanceled( PopupMenuEvent e ) {}



	public void componentResized( ComponentEvent e ) {}



	public void componentMoved( ComponentEvent e ) {}



	public void componentHidden( ComponentEvent e ) {}

}

Edited by Guest
  • 3 weeks later...
Posted (edited)

Hi cobra

The last modified version by Jesse Barnum is ok. You need to create a ScriptMaster parameter (if you prefer, an "input variables" in ScriptMaster.fp7) named "choices" and then, in Filemaker, you can pass a value list containing the different choices.

Edited by Guest

This topic is 5713 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.