Hello
I use ActiveButton= MC_Text_getactive to select a Text that has been defined on the screen. This allow me to simulate buttons on screen that I use to start some special task. That work perfectly, but the problem is the activated Text is kept selected so the button manually selected, keep to be selected until I manually un-selected it.
I need to find a way execute the attached function (Attached to the button) only once
Hope I'm clear
Martin
MC_GetActive: How to force an un select the active Text
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: MC_GetActive: How to force an un select the active Text
Hm, perhaps with a Boolean true/false variable that's only true once (the first time the text box is selected)?
In pseudo-code, I was thinking about something like this:
In pseudo-code, I was thinking about something like this:
Code: Select all
Variables:
IntrabarPersist buttonA_Active(false);
activeA = MC_Text_GetActive(idButtonA);
if (activeA and buttonA_Active = false) then
// Do the code that needs to be executed once selected
buttonA_Active = true;
end;
// Reset variable when the button isn't selected
if (activeA = false) then
buttonA_Active = false;
Re: MC_GetActive: How to force an un select the active Text
Hello JosHm, perhaps with a Boolean true/false variable that's only true once (the first time the text box is selected)?
In pseudo-code, I was thinking about something like this:
Code: Select all
Variables:
IntrabarPersist buttonA_Active(false);
activeA = MC_Text_GetActive(idButtonA);
if (activeA and buttonA_Active = false) then
// Do the code that needs to be executed once selected
buttonA_Active = true;
end;
// Reset variable when the button isn't selected
if (activeA = false) then
buttonA_Active = false;
That what I came out with an hour after the post. I should have use it before because I was using this technique since early 80' when I was coding electronic switch. Christmas festivities...
To be valid, the reading of the text_GetActive need to be different of the previous reading
To make sure the the read value is kept, the variable need to be define with IntrabarPersist
Intrabarpersist GetActive_PreviousValue (0);
Code: Select all
ActiveButton= MC_Text_getactive;
// Print (activeButton:0:0);
If ActiveButton <> GetActive_PreviousValue then begin
// Print (ActiveButton:0:0, " ", GetActive_PreviousValue:0:0);
If activeButton = Button_0_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_1_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_2_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_3_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_4_Val then playsound("C:\CLICK.WAV") ;
If activebutton = Button_5_Val then Boolean_val = Centerfromarrow;
If activeButton = Button_6_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_7_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_8_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_9_Val then Boolean_val = EraseArrow;
If activeButton = Button_Recalc_Val then recalculate;
GetActive_PreviousValue = Activebutton;
end;
Re: MC_GetActive: How to force an un select the active Text
That´s really interessting.
Can you show me how you code your buttons that they stay at the right of the chart?
What if you are resize the chart or Bars?
thx wegi
Can you show me how you code your buttons that they stay at the right of the chart?
What if you are resize the chart or Bars?
thx wegi
Re: MC_GetActive: How to force an un select the active Text
Here is the code for the indicator called: MouseClick_BarNumber_Menu_1. The resize won't affect the look.That´s really interessting.
Can you show me how you code your buttons that they stay at the right of the chart?
What if you are resize the chart or Bars?
thx wegi
At the moment, only two function is installed. One to center the charts over an arrow. Use to look at an area using a smaller time frame. The other one is to erase an arrow.
The indicator has many functions to capture data from a mouse click to enabled a function when a button is hit. This is a work in progress. The mouse click will capture bar data and saved them in a Text file. I use this file to transfert data to my Excel worksheet
If you want to execute a task, write the work to do under a function. This function to be called when the desired button is hit
Martin
Code: Select all
//By Martin Theriault (arjfca)
[ProcessMouseEvents = true]
Input:
WorkSpaceNumber (0),
ShowMenu (True);
vars:
SpacetoRight (0),
ClickonMargin (False),
BarNumberOfTheLastBar(0),
Comma (""),
BarInfo_Str (""),
Astring (""),
vClickBarHigh_S (""),
vClickBarLow_S (""),
vClickBarOpen_S (""),
vClickBarClose_S (""),
vClickPrice_S (""),
vClickBarNbr(0),
vLastBar(0),
vBarsAgo(0),
vClickBarHigh(0),
vClickBarLow(0),
vClickBarOpen (0),
vClickBarClose (0),
vClickPrice (0),
vclickdatetime (0),
vclickDateTime_S (""),
AmouseClick (false),
Amouseclick_CTRL (False),
VclickDateTime_CTRL (0),
ClickTime (0),
clickDate (0),
UpArrow (True),
BarNumberTarget (0),
GVVal (0),
scale (""),
HighestPrice (0),
LowestPrice (0),
RightSpace (0),
UpperPart (0),
LowerPart (0),
Button_1_High (0),
Button_1_Low (0),
Button_2_High (0),
Button_2_Low (0),
Button_3_High (0),
Button_3_Low (0),
Button_4_High (0),
Button_4_Low (0),
Button_5_High (0),
Button_5_Low (0),
Button_1 (False),
Button_2 (false),
Button_3 (false),
Button_4 (false),
Button_5 (false),
Boolean_Val (False),
TextVal (0),
Button_1_Val (0),
Button_2_Val (0),
Button_3_Val (0),
Button_4_Val (0),
Button_5_Val (0),
Button_6_Val (0),
Button_7_Val (0),
Button_8_Val (0),
Button_9_Val (0),
Button_0_Val (0),
Button_ReCalc_Val (0),
RightMargin (0),
TheSpaceToRight (0),
LeftDateTime (0),
LeftSideOfScreenDate (0),
ActiveButton (0),
ListID(0),
NotesNumber(0),
NotesString(""),
TextDawing_Number(0),
GetActiveDone (False),
Intrabarpersist GetActive_PreviousValue (0);
Once begin
Comma = ",";
scale = scalestring;
Button_0_Val = Text_New_S(date, Time_s -1,0,"0");
Button_1_Val = Text_New_S(date, Time_s -1,0,"1");
Button_2_Val = Text_New_S(date, Time_s -1,0,"2");
Button_3_Val = Text_New_S(date, Time_s -1,0,"3");
Button_4_Val = Text_New_S(date, Time_s -1,0,"4");
Button_5_Val = Text_New_S(date, Time_s -1,0,"Jp To");
Button_6_Val = Text_New_S(date, Time_s -1,0,"6");
Button_7_Val = Text_New_S(date, Time_s -1,0,"7");
Button_8_Val = Text_New_S(date, Time_s -1,0,"8");
Button_9_Val = Text_New_S(date, Time_s -1,0,"Rmv A");
Button_ReCalc_Val = Text_New_S(date, Time_s -1,0,"ReCalc");
SetMenuAttribute(Button_1_Val);
SetMenuAttribute(Button_2_Val);
SetMenuAttribute(Button_3_Val);
SetMenuAttribute(Button_4_Val);
SetMenuAttribute(Button_5_Val);
SetMenuAttribute(Button_6_Val);
SetMenuAttribute(Button_7_Val);
SetMenuAttribute(Button_8_Val);
SetMenuAttribute(Button_9_Val);
SetMenuAttribute(Button_0_Val);
SetMenuAttribute(Button_Recalc_Val);
Text_SetStyle(button_recalc_Val,0,2);
ListID = ListS.New;
GetActive_PreviousValue = Activebutton;
end;
If LastBarOnChart then begin
//Get the location of the margin
HighestPrice = Getappinfo(aiHighestDispValue);
Lowestprice = Getappinfo(aiLowestDispValue);
RightMargin = Getappinfo(aiRightDispDateTime);
TheSpaceToRight = Getappinfo(aiSpacetoRight);
LeftDateTime = Getappinfo(aiLeftDispDateTime );
LeftSideOfScreenDate = JulianToDate(GetAppInfo(aiLeftDispDateTime));
TextVal = Text_setLocation_BN(Button_0_val,Barnumber + (TheSpaceToRight*.9), HighestPrice);
TextVal = Text_setLocation_BN(Button_1_val,Barnumber + (TheSpaceToRight*.9), (highestprice - (HighestPrice-Lowestprice) *.10));
TextVal = Text_setLocation_BN(Button_2_val,Barnumber + (TheSpaceToRight*.9), (HighestPrice - (HighestPrice-Lowestprice) *.20));
TextVal = Text_setLocation_BN(Button_3_val,Barnumber + (TheSpaceToRight*.9), (HighestPrice - (HighestPrice-Lowestprice) *.30));
TextVal = Text_setLocation_BN(Button_4_val,Barnumber + (TheSpaceToRight*.9), (HighestPrice - (HighestPrice-Lowestprice) *.40));
TextVal = Text_setLocation_BN(Button_5_val,Barnumber + (TheSpaceToRight*.9), (HighestPrice - (HighestPrice-Lowestprice) *.50));
TextVal = Text_setLocation_BN(Button_6_val,Barnumber + (TheSpaceToRight*.9), (HighestPrice - (HighestPrice-Lowestprice) *.60));
TextVal = Text_setLocation_BN(Button_7_val,Barnumber + (TheSpaceToRight*.9), (HighestPrice - (HighestPrice-Lowestprice) *.70));
TextVal = Text_setLocation_BN(Button_8_val,Barnumber + (TheSpaceToRight*.9), (HighestPrice - (HighestPrice-Lowestprice) *.80));
TextVal = Text_setLocation_BN(Button_9_val,Barnumber + (TheSpaceToRight*.9), (HighestPrice - (HighestPrice-Lowestprice) *.90));
TextVal = Text_SetLocation_s(Button_ReCalc_Val, LeftSideOfScreenDate, DateTime2ELTime_s(leftDateTime), HighestPrice );
ActiveButton= MC_Text_getactive;
// Print (activeButton:0:0);
If ActiveButton <> GetActive_PreviousValue then begin
// Print (ActiveButton:0:0, " ", GetActive_PreviousValue:0:0);
If activeButton = Button_0_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_1_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_2_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_3_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_4_Val then playsound("C:\CLICK.WAV") ;
If activebutton = Button_5_Val then Boolean_val = Centerfromarrow;
If activeButton = Button_6_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_7_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_8_Val then playsound("C:\CLICK.WAV") ;
If activeButton = Button_9_Val then Boolean_val = EraseArrow;
If activeButton = Button_Recalc_Val then recalculate;
GetActive_PreviousValue = Activebutton;
end;
end;
if MouseClickshiftPressed then begin
Amouseclick = True;
vClickBarNbr = MouseClickBarNumber;
//print ("MS: ", vClickBarNbr:0:0);
vclickdatetime = MouseClickDateTime;
vClickPrice = MouseClickPrice;
end;
If amouseclick = true then begin
vLastBar = BarNumber + MaxBarsBack;
vBarsAgo = vLastBar-vClickBarNbr ;
if vBarsAgo >= 0 then begin
vclickbarhigh = high[vBarsAgo];
vClickBarOpen_S = NumtoStr(Open[vBarsAgo],5);
vClickBarHigh_S = NumToStr(high[vBarsAgo],5);
vClickBarLow_S = NumToStr(low[vBarsAgo],5);
vClickBarClose_S = NumToStr(Close[vBarsago],5);
vClickPrice_S = numtostr(vClickPrice,5);
GvSetNamedString("BarInfo",vClickBarOpen_S + comma + vClickBarHigh_S + comma + vClickBarLow_s + comma + vClickBarClose_S + comma +
GetSymbolName+ comma + scale + comma + vClickPrice_S + comma + DateTimeToString(vclickdatetime));
Barinfo_Str = GVGetNamedString("BarInfo","Error");
filedelete("G:\BarInfo.txt");
fileappend("G:\BarInfo.txt",Barinfo_Str + comma + GetSymbolName + comma + scale +
comma + vClickPrice_S + comma + DateTimeToString(vclickdatetime));
//print ("O: ", vClickBarOpen_S, " H: ", vClickBarHigh_S, " L: ",vClickBarLow_S, " C: ", vClickBarClose_S , " CP: ", vClickPrice_S, "BN: ", MouseclickBarnumber, " DT: ", Mouseclickdatetime);
//playsound("C:\Program Files (x86)\Microsoft Office\Office14\MEDIA\CLICK.WAV") ;
Arw_New_DT(vclickdatetime, vClickPrice ,UpArrow);
//Print (vclickprice:5:5, " CDT: ", vclickdatetime:10:10, " LTC: ", (LastCalcJDate +(LastCalcSSTime * ELTimeToDateTime_s(1))):10:10); //vClickBarNbr:0:0, " ", (barnumber + maxbarsback ));
DateTime2ELTime(GetAppInfo(aiRightDispDateTime));
//print (vclickprice:5:5, " ", upperpart:5:5, " ", vClickBarNbr:0:5 , " " , (barnumber + maxbarsback )) ;
If vClickPrice > high[vBarsAgo] then
Astring = "LONG" + comma + vClickBarOpen_S + comma + vClickBarClose_S
else
Astring = "SHORT" + comma + vClickBarClose_S + vClickBarOpen_S ;
GVVal = GVSetNamedString("A_BAR_DATA",astring + comma + GetSymbolName + comma + scalestring );
GVVal = GVSetNamedString("Time_Date_DATA", numtostr(vclickdatetime,2));
{ clickonmargin = false;
If vclickdatetime -.00002 > (LastCalcJDate +(LastCalcSSTime * ELTimeToDateTime_s(1))) then begin
// print ("bn ", BarNumberOfTheLastBar:0:0, " ", "vc ",vClickBarNbr:0:0, " VCT: ",vclickdatetime) ;
ClickonMargin = true;
Button_1_High = Highestprice;
Button_1_Low = HighestPrice - (.1 * (HighestPrice-LowestPrice));
Button_2_High = highestprice - ((HighestPrice-Lowestprice) *.20);
Button_2_Low = HighestPrice - ((HighestPrice-lowestprice) *.30);
Button_3_High = highestprice - ((HighestPrice-Lowestprice) *.45);
Button_3_Low = HighestPrice - ((HighestPrice-lowestprice) *.55);
Button_4_High = highestprice - ((HighestPrice-Lowestprice) *.70);
Button_4_Low = HighestPrice - ((HighestPrice-lowestprice) *.80);
Button_5_High = HighestPrice - (.90 * (HighestPrice-LowestPrice));
Button_5_Low = Lowestprice;
// print (Button_1_High:5:5, " ", Button_1_Low:5:5 );
If VclickPrice <= Button_1_High and vClickPrice >= Button_1_Low then Button_1 = True;
If VclickPrice <= Button_2_High and vClickPrice >= Button_2_Low then Button_2 = True;
If VclickPrice <= Button_3_High and vClickPrice >= Button_3_Low then Button_3 = True;
If VclickPrice <= Button_4_High and vClickPrice >= Button_4_Low then Button_4 = True;
If VclickPrice <= Button_5_High and vClickPrice >= Button_5_Low then Button_5 = True;
end;
If Button_1 = true then begin
if GVGetNamedString("ShowPrevDayTime","Error SetShoPrevDay") = "True" then GVSetNamedString("ShowPrevDayTime" , "False" )
else begin
GVSetNamedString("ShowPrevDayTime" , "True" );
end;
//Print (GVGetNamedString("ShowPrevDayTime","Error SetShoPrevDay"));
end;
if clickonmargin = true then begin
If button_2 = true then begin
playsound("G:\Users\Utilisateur\Documents\Bourse\Sound\Button 2.wav");
ShowLineForThelastprice;
end;
//If Button_3 = true then Boolean_val = Centerfromarrow;
If button_4 = true then Boolean_val = EraseArrow;
If Button_5 = true then begin
print("Button 5");
//playsound("C:\Program Files (x86)\Microsoft Office\root\Office16\MEDIA\CLICK.WAV") ;
playsound("C:\CLICK.WAV") ;
end ;
end;}
end;
end;
If amouseclick = true and lastbaronchart_S then begin
print ("amouse click");
amouseclick = false;
//If ClickonMargin = false then playsound("C:\Program Files\Microsoft Office 15\root\office15\MEDIA\CLICK.WAV") ;
If ClickonMargin = false then playsound("G:\Users\Utilisateur\Documents\Bourse\Sound\Click.wav");
Print ("Click");
clickonmargin = false;
end;
If mouseclickctrlpressed then begin
amouseclick_ctrl = True;
VClickDateTime_CTRL = MouseClickDateTime;
GVVal = GVSetNamedString("Time_Date_DATA", numtostr( VClickDateTime_CTRL ,2));
end;
If amouseclick_CTRL = true and lastbaronchart_S then amouseclick_CTRL = false;
Value1 = Text_GetFirst(6);