cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Rob
Rob
Level II

Run self-written JSL script with a shortcut

Hi everybody!

 

When looking at some data in the Graph Builder I can mark one or more points in the plot. After marking something I would like to run a self-written JSL script (which plots the marked rows in the data table in some other way in a new window) by hitting some keyboard shortcut. I have to do that many times and I would like to avoid opening the script or switching to the scripting window and hitting start every time. Is it possible to assign a keyboard shortcut to run a specific script when having the Graph Builder in the foreground?

 

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Run self-written JSL script with a shortcut

Hi. Attached you will find an example script that uses mousebox.

 

Mousebox is very useful for interactive graphics, however, some of the functionality is not very well documented.   

 

You do need to use mousebox if you are willing to click on a button. 

 

This script runs a task when the home key on the keypad is clicked. A couple things to note about Mousebox, you can only specify one display box for the mousebox argument. However, if you make it a container display box, like VListBox, or HListBox, then multiple objects can be accessed via mousebox functions. The other things to note is that there are multiple mousebox functions and there is an issue with losing focus. Read on.

 

The mousebox function that is used fro this example is the SetKey() function.  As documented by Craig Hales, Dec 2015, using some of the built-in keyboard shortcuts can cause the mousebox to loose focus. So this script adds a button to refocus so it can be reset. To test, use select one of the hand tools like the select (fat plus sign) then select some arrow keys and the keys ar no longer displayed. Click on the Refocus button, then click on the arrow keys and the text for teh buttons now appear.

 

To test the functionality, select several points from the Graph Builder plot. selct some arrow keys, then select Home. A window of your selected yourw will appears. Make another set of selections, and click on Home again.

 

This Refocus button also provides an example if you wish to use a button box and not a keyboard key to initiate a task.  For demonstartion, I kept a textbox that prints the keyboard key. I learned a lot from Craig Hales example in 2015, so the script contains the link and, the this script's set key function emulates his example.

 

This script was tested in JMP 12, 13 and 14. 

View solution in original post

Jeff_Perkinson
Community Manager Community Manager

Re: Run self-written JSL script with a shortcut

@gzmorgan0's soution is a good one, but it does seem to rely on creating your Graph Builder (or other report) in JSL in order to add the mousebox  and its corresponding keyboard shortcut.

 

What you seemed to describe in your original post was creating a Graph Builder report interactively, selecting some points and then doing something on the selected rows.

 

For this use case, you can create a JMP Add-in to run your JSL on the selected rows and assign a keyboard shortcut for it.

 

Imagine that you have this JSL which colors and marks the selected rows of the current data table blue X.

 

 

current data table()<<colors("Blue");

current data table()<<Markers("X");

You can use File->New Add-in to create a new add-in.

Parallels DesktopScreenSnapz051.png

In the Add-in Builder window you can assign a shortcut key to menu command that you create for the add-in.

Parallels_DesktopScreenSnapz052.png

 

 

After saving and installing this add-in, whenever I hit Ctrl-Shift-B I'll color and mark the selected rows of the current data table with a blue X. 

 

Of course my script could do much more if I'm willing to make some assumptions about when I might use it (e.g., only when I've got data tables of a certain structure, or only when I am looking at a particular platform). 

-Jeff

View solution in original post

4 REPLIES 4
gzmorgan0
Super User (Alumni)

Re: Run self-written JSL script with a shortcut

Hi. Attached you will find an example script that uses mousebox.

 

Mousebox is very useful for interactive graphics, however, some of the functionality is not very well documented.   

 

You do need to use mousebox if you are willing to click on a button. 

 

This script runs a task when the home key on the keypad is clicked. A couple things to note about Mousebox, you can only specify one display box for the mousebox argument. However, if you make it a container display box, like VListBox, or HListBox, then multiple objects can be accessed via mousebox functions. The other things to note is that there are multiple mousebox functions and there is an issue with losing focus. Read on.

 

The mousebox function that is used fro this example is the SetKey() function.  As documented by Craig Hales, Dec 2015, using some of the built-in keyboard shortcuts can cause the mousebox to loose focus. So this script adds a button to refocus so it can be reset. To test, use select one of the hand tools like the select (fat plus sign) then select some arrow keys and the keys ar no longer displayed. Click on the Refocus button, then click on the arrow keys and the text for teh buttons now appear.

 

To test the functionality, select several points from the Graph Builder plot. selct some arrow keys, then select Home. A window of your selected yourw will appears. Make another set of selections, and click on Home again.

 

This Refocus button also provides an example if you wish to use a button box and not a keyboard key to initiate a task.  For demonstartion, I kept a textbox that prints the keyboard key. I learned a lot from Craig Hales example in 2015, so the script contains the link and, the this script's set key function emulates his example.

 

This script was tested in JMP 12, 13 and 14. 

Rob
Rob
Level II

Re: Run self-written JSL script with a shortcut

Wow, that's so cool! Thanks!
Jeff_Perkinson
Community Manager Community Manager

Re: Run self-written JSL script with a shortcut

@gzmorgan0's soution is a good one, but it does seem to rely on creating your Graph Builder (or other report) in JSL in order to add the mousebox  and its corresponding keyboard shortcut.

 

What you seemed to describe in your original post was creating a Graph Builder report interactively, selecting some points and then doing something on the selected rows.

 

For this use case, you can create a JMP Add-in to run your JSL on the selected rows and assign a keyboard shortcut for it.

 

Imagine that you have this JSL which colors and marks the selected rows of the current data table blue X.

 

 

current data table()<<colors("Blue");

current data table()<<Markers("X");

You can use File->New Add-in to create a new add-in.

Parallels DesktopScreenSnapz051.png

In the Add-in Builder window you can assign a shortcut key to menu command that you create for the add-in.

Parallels_DesktopScreenSnapz052.png

 

 

After saving and installing this add-in, whenever I hit Ctrl-Shift-B I'll color and mark the selected rows of the current data table with a blue X. 

 

Of course my script could do much more if I'm willing to make some assumptions about when I might use it (e.g., only when I've got data tables of a certain structure, or only when I am looking at a particular platform). 

-Jeff
Rob
Rob
Level II

Re: Run self-written JSL script with a shortcut

That's even much better, faster and easier! Thanks!