Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to navigate through toolbar buttons by using arrow keys?
#1
I have created a simple toolbar, that is, in fact, a virtual keyboard, so that, when I invoke it, I can insert any character by clicking the proper button. I use it when I write long documents and I need quickly a special character.
But it would be better to use it without having to take off an hand from the material keyboard and to click on it with the mouse.
So, I need a way for navigating through the buttons of the virtual keyboard by using the arrow keys of the material keyboard and execute one of them by pressing Enter on the material keyboard.
#2
Code:
Copy      Help
int+ g_tbkb_aw=win
int tb=win("TOOLBAR19" "QM_Toolbar")
if(!tb) tb=mac("Toolbar19")
act id(9999 tb)

This code activates toolbar "Toolbar19". Then you can select buttons with arrow keys, press button with spacebar, calcel with Esc.

Also create toolbar hook function that will deactivate toolbar window.

Function tbkb_hook
Code:
Copy      Help
;/
function# hWnd message wParam lParam

int+ g_tbkb_aw

sel message
,case WM_COMMAND
,if(g_tbkb_aw and hWnd=win)
,,act g_tbkb_aw; err
,g_tbkb_aw=0
,
,case WM_ACTIVATE
,if(wParam=0) g_tbkb_aw=0

And assign it to the toolbar (in Properties).
#3
I have created a new macro containing this code:

int+ g_tbkb_aw=win
int tb=win("TOOLBAR19" "QM_Toolbar")
if(!tb) tb=mac("Toolbar19")
act id(9999 tb)

I have replaced Toolbar19 with the name of my virtual keyboard, that is a QM toolbar.
I have created a new function named tbkb_hook:

;/
function# hWnd message wParam lParam

int+ g_tbkb_aw

sel message
,case WM_COMMAND
,if(g_tbkb_aw and hWnd=win)
,,act g_tbkb_aw; err
,g_tbkb_aw=0
,
,case WM_ACTIVATE
,if(wParam=0) g_tbkb_aw=0

Now, when I execute the macro, the virtual keyboard appears and I see that the arrow keys allow me to move around the virtual buttons. Then I have tried to type some keys in Windows Notepad, but when I press the space bar, my virtual keyboard disappears, having written nothing in Notepad. I have noticed that now the virtual keyboard takes the focus, so that when it appears the Notepad window is no more active.

I think that perhaps the problem is that I have not understood your last phrase:
"assign it to the toolbar (in Properties)"
How shall I do it?
#4
When you run the code, toolbar is activated (Notepad deactivated). It allows you to use arrow keys, spacebar and Esc. When you press spacebar, it presses the highlighted button.

Function tbkb_hook is used to deactivate toolbar (activate Notepad) when you press spacebar. To assign it to the toolbar, open the toolbar, go to Properties, Toolbar properties, and type tbkb_hook in the Hook function field.


Forum Jump:


Users browsing this thread: 1 Guest(s)