Try this: https://fxdreema.com/shared/WPSiKSY7b
Here I create the button with name MyButtonName in "on Init", because I only need to do it once when the EA starts. Then in "on Chart" I detect when it was clicked (block 3). Then I load that button (block 4), check whether it is pressed or not (block 5) and do some actions depending on that. I change its name (6 and 7).
Blocks 4-5-6-7 can also be used at any time in "on Init". Depends on how what you want to do. You say that you want to turn off blocks, so in my example you can replace block 8 with the turn off block. Or set the value of some variable, which will then be checked in "on Init". But also, blocks 4-5 would do pretty much the same job if they are in "on Tick".
It seems that the Chart event (OnChartEvent() MQL function) doesn't work when testing on visual mode, it only works when you run the EA live.