I sort of agree and disagree with the usage of tabs and enter. In the data entry of numerical data, it is quite easy to do the majority of entry from the numeric keypad with your right hand, and set up the OK button to be the default button to store/process the data i.e. '%`tt[OK]'. Use the left hand on the tab key.
However, if the enter key could be detected using a keyboard monitor (which it can't) and the id of the data entry field detected (which it can be) then your proposal would work. Unfortunately, I tried a simple program for this and the Enter key does not seem to be detected by the keyboard monitor call back. The Return key acts the same. However, Control+M which is a carriage return character is detected, but requires too many fingers to make it simple.
Using the 'Enter' as an accelerator key and detecting if the last control is active does work. Move to the next control under the control of a callback is achieved with set_highlighted@. To select the text in the first control, it is necessary to call window_update and not just allow the update that occurs on return from the callback with ienter_monitor = 1. The keyboard monitor bits are not required but are shown for information.
Ian
PS here is the code I tried, but as the enter key did not respond to the keyboard monitor, I tried the 'Plus' key as a demo. The demo also responds to Enter using the %ac function.
winapp
program keyboard_monitor_program
implicit real*8 (a-h,o-z)
include <windows.ins>
external keyboard_monitor,ienter_monitor
common/data_stuff/data1,data2,data3
common/focus_control/ifocus,ncontrol,icontrol(100)
i=ifw()
call add_focus_monitor@(ifw)
call add_keyboard_monitor@(keyboard_monitor)
data1 = 0d0
data2 = 0d0
data3 = 0d0
ncontrol = 3
i=winio@('%ca[Keyboard monitor]&')
i=winio@('%ac[Enter]&',ienter_monitor)
i=winio@('%ff%rf%lc&',data1,icontrol(1))
i=winio@('%ff%rf%lc&',data2,icontrol(2))
i=winio@('%ff%rf%lc',data3,icontrol(3))
call remove_focus_monitor@(ifw)
end
integer*4 function keyboard_monitor()
implicit real*8 (a-h,o-z)
include <windows.ins>
common/data_stuff/data1,data2,data3
keyboard_monitor=1
ikey = clearwin_info@('KEYBOARD_KEY')
if(ikey .eq. 43)then
!plus key pressed so process data and clear input
print *,data1,data2,data3
data1 = 0d0
data2 = 0d0
data3 = 0d0
endif
end
integer*4 function ienter_monitor()
implicit real*8 (a-h,o-z)
include <windows.ins>
common/data_stuff/data1,data2,data3
common/focus_control/ifocus,ncontrol,icontrol(100)
ienter_monitor=1
!enter key pressed so process data and clear input
if(ifocus .eq. icontrol(ncontrol))then
!process the data
! print *,'enter in last field',data1,data2,data3
data1 = 0d0
data2 = 0d0
data3 = 0d0
call window_update@(data1)
call window_update@(data2)
call window_update@(data3)
call set_highlighted@(icontrol(1))
else
!or move to next field
do i=1,ncontrol-1
if(ifocus .eq. icontrol(i))then
call set_highlighted@(icontrol(i+1))
exit
endif
enddo
endif
end
integer*4 function ifw()
include <windows.ins>
common/focus_control/ifocus,ncontrol,icontrol(100)
ifw=2
ifocus=clearwin_info@('FOCUSSED_WINDOW')
end