Support Board
Date/Time: Tue, 26 Nov 2024 06:37:29 +0000
Post From: Can SetCustomStudyControlBarButtonEnable be put in sc.SetDefaults ?
[2024-01-03 10:11:58] |
PS2004 - Posts: 47 |
I like to do everything which is Button or MenuItem related outside the sc.SetDefaults block. There are two main reasons for this: 1. Because of this part of the documentation here: ACSIL Interface Members - Variables and Arrays: sc.SetDefaults When using ACSIL Functions within the sc.SetDefaults code block and those functions interact with the chart, they will have no effect. They will return and do nothing.
I don't necessarily think that this applies for the CS Buttons too, since it works, but just to be sure.2. This maybe not applies for your specific case, but here is another quote from this part of the documentation: If you modify the source code for a study and rebuild the DLL when an instance of the study is on a chart and the chart is open, and you do not remove the study from the chart and add it again, then all of the default settings like Input and Subgraphs settings in the sc.SetDefaults code block will not change back to defaults. They will remain as they were previously were.
This means that if you modify the code and rebuild it, during the development phase, and as you should, you specify an sc.LastCallToFunction block which resets the name of the Buttons, it won't be renamed. Thus if you include the naming of the Button in the sc.SetDefaults block, you need to write the same code elsewhere for a fluid development process.My method: I use a persistent variable called "runOnce", which runs only once, then never again, until the Study is closed/rebuilded, etc. In that "runOnce" block, I initialize every MenuItem, Button, etc. I hope this helps! |