Have you ever had to develop an
application that was data entry intensive and the users insist
that the enter key move them along from field to field. Usually
users require this feature because it is what they are used to or
because of the position of the enter and tab keys on the keyboard
itself. An easy way to accomplish this is to simulate the
pressing of the tab key whenever the user hits the enter key by
simply posting a message to the windows que. Post is a
Powerscript function that adds a message to the message queue for
a window. Although not spelled out in the help it also can add
messages for controls, including datawindows. By sending the
message WM_KEYDOWN (9) with the Virtual Key code for the Tab key
(256) we achieve the desired result.
In the datawindow, declare an
event mapped to pbm_dwnprocessenter in your datawindow and add
the following line of code:
Post( Handle(this),256,9,0 )
Return 1
This technique also works well on
window controls, such as moving between single line edits. By
mapping an event to pbm_keydown and placing the following lines
of code.
IF key = KeyEnter! THEN
Post(Handle(this), 256,9,0)
END IF
This last tip does not work well
with buttons since the hitting of the Enter key actually triggers
the clicked event on the button when it is the default button.
However placing this code in the clicked event alleviates that
problem. Note that the button still needs a pbm_keydown event as
noted above if it is not a default button to process the enter as
a tab.
IF KeyDown(KeyEnter!) THEN
Post(Handle(this), 256, 9 ,0)
RETURN 0
END IF
You can use the Send() function in
place of the Post() function, both seem to work well. Try to
persuade users against this if possible and se this tip only as a
last resort since changing default behaviors can cause side
effects
|