12-12-2016 12:23 PM
My current start script sets up custom memus when I load up diadem. Part of this process involves reseting the menus so that I start fresh before adding any bars/buttons. Unfortunatly, if the user has saved some script shortcuts they are erased next time DIAdem loads up.
I am trying to write some code to preserve their script shortcuts. I have been sucessful when running code from the scripts editor window but I cant seem to reteive any stored scripts when using the same code when diadem starts up.
For instance, if you run the following function at startup none of the saved script shortcuts show up. Any ideas for how to get around this??
Function GetScriptsArray
Dim ScriptButtons : Set ScriptButtons = Barmanager.Bars("SCRDIAdemScriptsFunc").UsedActionObjs
Dim ScriptsArray(12)
Dim ScriptButton
Dim i : i = 0
For Each ScriptButton In ScriptButtons
If i < 12 Then
ScriptsArray(i) = ScriptButton.Caption
ScriptsArray(i) = replace(ScriptsArray(i), "Script: ", "")
ScriptsArray(i) = replace(ScriptsArray(i), "Scri&pt: ", "") 'Sometimes an ampersand gets thrown in there
Msgbox(scriptsArray(i))
End If
i = i + 1
Next
GetScriptsArray = ScriptsArray
End Function
12-14-2016 07:26 AM
So I've given up on trying to read in the script presets using a start script. Instead, I'm attempting to recreate the current script preset bars and buttons so that I can save their presets outside the DDD file.
1.) Is there a way to handle the click event of an actionobj so that I can tell if there was a right or left click?
2.) Is there a way to overload the click code on the native script preset buttons so that I can add some custom code to save the users presets?
12-15-2016 03:11 PM
Hi,
In order to remove the script shortcuts, you would need to remove them using a function call similar to this:
BarManager.Bars("SCRDIAdemScripts").UsedActionObjs.Remove(DelActionObj.ID)
or
BarManager.Bars.Remove("SCRDIAdemScripts")
Theoretically, you could loop through all of the bars in the BarManager and remove everything which it sounds like you might be doing. If you are iterating over all the Bars and ActionObjects, then you can simply check for, and avoid deleting, the pre-included bars: SCRDIAdemScripts, SCRDialogBoxTemplates, SCRDIAdemScriptsFunc. You can find the Bar IDs and Object IDs by holding Ctrl+Shift and then hovering over the individual Action Objects.
I hope this helps!