Hi there,
I am figuring out how to code to identify whether a rectangle ID is manually selected on a chart. My thought was to get the rectangle ID of a rectangle using keyword RectangleGetActive. After a number of times of debugging the coding, I realize that the keyword does not work the way I expected, because a rectangle can become active by manually selecting it, or by executing codes like RectangleSetColor. I tried to look for other keywords and happened to find that there are keywords doing a similar job for trend line, arrow, and text. They are MC_TL_GetActive (NOT TL_GetActive), MC_Arw_GetActive (NOT Arw_GetActive), and MC_Text_GetActive (NOT Text_GetActive). In these cases, if a drawing object is not manually selected, the MC_xxx_GetActive keyword will return a value of -1 rather than a positive ID number.
I have two questions:
1) Is there any way to code a workaround that can identify whether a rectangle ID is manually selected?
2) Is there any plan for MC to add keyword MC_RectangleGetActive?
Thanks,
McGeorge
Manually Selected Rectangle [SOLVED]
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Manually Selected Rectangle
I think it might be possible with an elaborate workaround: if the code keeps track of which rectangles it affects (and thus make active), then when a rectangle becomes active without code having used that rectangle last, then that rectangle is probably manually selected.1) Is there any way to code a workaround that can identify whether a rectangle ID is manually selected?
I want to know this as well, since it for sure seems like a good feature to have.2) Is there any plan for MC to add keyword MC_RectangleGetActive?
Re: Manually Selected Rectangle [SOLVED]
Thanks Josh.I think it might be possible with an elaborate workaround: if the code keeps track of which rectangles it affects (and thus make active), then when a rectangle becomes active without code having used that rectangle last, then that rectangle is probably manually selected.1) Is there any way to code a workaround that can identify whether a rectangle ID is manually selected?
I want to know this as well, since it for sure seems like a good feature to have.2) Is there any plan for MC to add keyword MC_RectangleGetActive?
After a number of trial and error, I found that a possible workaround was: Step 1 - right at the beginning of the coding, assign the Rectangle ID of the manually selected rectangle to a variable using RectangleGetActive keyword, and Step 2 - at the end of the coding, reactivate the manually selected rectangle using keywords like RectangleSetXXX. Step 2 is critical if the coding involves activation of rectangles other than the manually selected one.
Multicharts Development team,
Though the workaround solves the problem, it is not a nice solution because it adds complexity to the coding and worsens its readability. It is also a fair request to make the MC_RectangleGetActive keyword available, where keywords performing the same task are already available to other types of drawings. Could the MC_RectangleGetActive keyword be added to Power Language in next release?
Thanks,
McGeorge