Show Custom Dialog / Capture Keystroke

Discussion created by deninger on Jul 9, 2014
Latest reply on Jul 11, 2014 by flukey

Consider the following:


Let's say I put up a custom dialog with two or three button choices (and no input fields). I can use Get (LastMessageChoice) to capture the button pressed and direct my script to handle the situation from there.


Some of my users don't like having to go to the mouse (they are keyboard snobs, if you like) and want to simply use a hot key to trigger the option they want to select (e.g. type 'n' to 'press' the New button, 'r' to 'press' the Refill button or 'd' to 'press' the Discontinue button).


I would love to find a way to capture keystrokes while Show Custom Dialog is running and be able to use this input to close the dialog and move on within a single script.


So I started thinking about using a Modal Window and script triggers with Get (TriggerKeystroke). As I consider it, though, I can visualize just two methods to proceed. Either:


1) I have to pause the script at the dialog step to wait for input either from the keyboard or the mouse. During this pause:

a) The keyboard input would trigger a second script to handle the keystroke and then I have to somehow return the result to the currently paused script. I can only think of 1 way to do this; global variables (and I try to avoid these!)

b) Pressing a button with the mouse could either set a local variable OR resume the script, but not both. So I would have to call another script for each button press instead (and then return the result to the paused script with the same limitations above)

c) With either user outcome, I have to resume the paused script after the user input (how!)




2) Stop one script and let the keystroke or mouse input start a new script to pick up where the last one left off. This has its own set of consequences:

a) The logic is split up and more difficult to follow

b) you have to do this EVERY time you bring up a dialog box in this fashion, so a script may have to be divied MANY times into constituent parts

c) having two or more break points in your logic (where dialogs are opened) creates the possibility of unforseen situations (bad programming, clever users doing things in an unanticipated way etc) that can possibly leave the data in limbo and not finished)


Any thoughts, insights or work-arounds would be most welcome.