Keyboard arrow keys do not change Selected bar after Clicking GuiButton

I am using GuiButton in my AFL. Based on the bar range selected, I do certain calculations on clicking the Button. I am able to catch the button click event and all calculations work fine. But facing an odd issue.
Steps when issue is found:

  1. Click on a Gui Button. Focus remains on button clicked (no problem).
  2. Use mouse to select some bar.
  3. After that I use keyboard Left arrow or Right arrow to select exact bar.
  4. But use of keyboard left arrow or right arrow does not change the selected bar. Bar selected by mouse continues to remain selected.

If I click on another Sheet or Chart or Another non-amibroker window, the Gui button loses focus and I am able to change Selected bar using keyboard arrow keys.
I am using ver 6.28.

Is there anything I can do within AFL to remedy the problem?

 SetOption("GuiEnableKeyboard", False)
2 Likes

Apparently the option is supposed to be set to true to enable bar selection by keyboard.

SetOption("GuiEnableKeyboard", True);

To me the option naming was kind of misleading because I thought it would enable/disable gui button selection by keyboard.

3 Likes

Thanks @codejunkie for your inputs.

Using either of the two options below did not allow me bar selection by keyboard once GUI button was clicked.
Adding

SetOption("GuiEnableKeyboard", False);

disabled navigation of GUI buttons using arrow keys.

Adding

SetOption("GuiEnableKeyboard", True);

enabled navigation of GUI buttons using arrow keys.

@aniruddhakhopkar I did a short test using:

SetOption("GuiEnableKeyboard", True);

following your steps and it works perfectly (AB 6.28.0 - 64-bit).

The critical point is Step 2. After clicking on any button you NEED to click on a bar with the mouse.

After that, I was able to navigate between bars using the arrows keys as it is usually done when no Gui button is used on the chart.

2 Likes

Thanks @beppe. Yes, it works perfectly with

SetOption("GuiEnableKeyboard", True);

On clicking a bar with mouse, the button also loses focus. How did I miss my own Step 2? Thanks for pointing it out.

Thanks @codejunkie and @beppe. Your inputs have resolved the problem.