Text_GetActive anomalies  [SOLVED]

Questions about MultiCharts and user contributed studies.
PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Text_GetActive anomalies

Postby PD Quig » 03 Mar 2015

I am experiencing cases where the Text_GetActive function thinks that text has been selected when it has not.

Here's what is happening: my code places text strings on the screen and when a text string is manually selected, a Text_GetActive loop gets entered and the signal takes various actions based on the underlying boolean variable getting flipped from true to false or vice versa. In another part of the code, I programmatically change the color of the text and switch the boolean under certain conditions. The idea is to have the signal make suggestions programatically yet allowing me to override the changes without having to turn automation off.

I noticed in testing that the program occasionally does not change the text color and underlying variable as expected. Upon investigating, I verified that the reason is that a loop which can only be entered when Text_GetActive is TRUE is being entered despite no text selection having been made. Can changing the color via code be fooling the Text_GetActive function?

Has anybody else seen this phenomenon?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Text_GetActive anomalies  [SOLVED]

Postby JoshM » 04 Mar 2015

Can changing the color via code be fooling the Text_GetActive function?
Yes. An 'active' text box is not only the text box that is selected, but the most recently created or used text box is also considered to be 'active'. Changing a text box's colour will then make it 'active', even if before that another text box has been selected.

I think that, instead of using Text_GetActive, you might need to use MC_Text_GetActive. This latter returns the ID of the currently selected (not active) text.

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Text_GetActive anomalies

Postby PD Quig » 04 Mar 2015

Josh,

Somehow I had missed seeing MC_Text_GetActive when looking at the Text Drawing page in Wiki. Using MC_Text_GetActive and making some modifications to code it all works. I had built my routine based on bowlesj3 InteractiveScriptBase code that uses Text_GetActive. http://www.multicharts.com/discussion/v ... f=5&t=7764

I think I ran into issues by adding too many text strings in combination with programmatic changes to those text strings.

Thanks!

PD


Return to “MultiCharts”