creating a shortcut key to toggle through a List
Posted: 15 Sep 2009, 17:59
Here is a simple way to create a new button (and shortcut key) that lets you toggle through a list of Main Panel tools - in this case, you can toggle the four different stroke types.
Do the following steps:
Part 1 - creating the button
1. Select and copy the script in the box below - all of it, as is.
2. create a new button in a panel and give it a name (I called mine ToggleList). Remember the panel's name too.
3. Edit the button and add a new command line by clicking on "Embedded George Script"
4. Paste the script you just copied into the window titled "Type Script's Command"
5. Press OK to close the script window and Press OK to close the button Editor.
Part 2 - assigning a shortcut key to the button
1. Press Control-K to open the Keyboard ShortCuts dialog window.
2. Pick a shortcut key.
3. Search for the button you just created which will be under the panel's name in the list. Example: "MyPanel:ToggleList"
4. Press Assign, then save by pressing OK
The new shortcut key should cycle you through all four stroke options/icons.
Additional ToggleLists for the Main Panel tools could be made by collecting an exact list of the option titles you want to toggle through and customize the embedded scripts in other buttons.
The ToggleList could also toggle ACROSS tool categories - for example all the various FILL options could be cycled through: Filled Stroke, Filled Line, Filled Rectangle, Filled Circle, Filled 2 Pts Circle, Filled 3 Pts Circle, etc.
Other kinds of ToggleLists could be created but the code lines which test the current state would have to be different.
This example also demonstrates the power of the Embedded Script feature in the Button Editor. I like it.
Sven
EDIT - (added a test to see if NONE of the four stroke tools were selected and if not then selects stroke Option1.)
Do the following steps:
Part 1 - creating the button
1. Select and copy the script in the box below - all of it, as is.
2. create a new button in a panel and give it a name (I called mine ToggleList). Remember the panel's name too.
3. Edit the button and add a new command line by clicking on "Embedded George Script"
4. Paste the script you just copied into the window titled "Type Script's Command"
5. Press OK to close the script window and Press OK to close the button Editor.
Part 2 - assigning a shortcut key to the button
1. Press Control-K to open the Keyboard ShortCuts dialog window.
2. Pick a shortcut key.
3. Search for the button you just created which will be under the panel's name in the list. Example: "MyPanel:ToggleList"
4. Press Assign, then save by pressing OK
The new shortcut key should cycle you through all four stroke options/icons.
Additional ToggleLists for the Main Panel tools could be made by collecting an exact list of the option titles you want to toggle through and customize the embedded scripts in other buttons.
The ToggleList could also toggle ACROSS tool categories - for example all the various FILL options could be cycled through: Filled Stroke, Filled Line, Filled Rectangle, Filled Circle, Filled 2 Pts Circle, Filled 3 Pts Circle, etc.
Other kinds of ToggleLists could be created but the code lines which test the current state would have to be different.
Code: Select all
// ToggleList.grg
// Svengali - Sept. 15, 2009
// Toggling or cycling through the four Stroke types
Param none
ScriptName = 'ToggleList'
option1 = "singledot"
option2 = "dot"
Option3 = "freehandline"
option4 = "freehandfill"
tv_GetActiveShape
parse result Shape
IF CMP(Shape, Option1)==0 && CMP(Shape, Option2)==0 && CMP(Shape, Option3)==0 && CMP(Shape, Option4)==0
tv_SetActiveShape Option1
END
IF CMP(Shape,Option1)
tv_SetActiveShape Option2
END
IF CMP(Shape,Option2)
tv_SetActiveShape Option3
END
IF CMP(Shape,Option3)
tv_SetActiveShape Option4
END
IF CMP(Shape,Option4)
tv_SetActiveShape Option1
END
Sven
EDIT - (added a test to see if NONE of the four stroke tools were selected and if not then selects stroke Option1.)