All,
Well, I figure since I'm asking questions here, I might as well put up something that I think others might find handy. Ever notice the "Select Field On Entry" option in text boxes? Ever been anoyed by the fact that if you click on one with a mouse, it has NO effect whatsoever. This feature is only useful when "Tabbing" through fields. I have created the following function called ENTERFIELD, which will take control, regardless of how "Select Field On Entry" is set. (I did this because after I created the fuction, I didn't want to go back and change all my text boxes on every screen.)
How it works: In the WHEN clause, simply place in one of the following:
=ENTERFIELD()
or
=ENTERFIELD(.T.)
(Note that the first has the same effect if you put in =ENTERFIELD(.F.), but sometimes I'm lazy...)
The difference between the two is as follows:
Setting the .T. value will cause the text box to behave exactly as the "Select Field On Entry", regardless of how you get in there. Setting it with a .F. value, will automatically place the cursor at the END of the information in the box.
Then ensure the following code is in your procedure file (set with "SET PROCEDURE TO <procname>":
PROCEDURE ENTERFIELD
PARAMETER M.SELECTFIELD
IF PARAMETERS() = 0
M.SELECTFIELD = .F.
ENDIF
*
KEYBOARD '{SHIFT+RIGHTARROW}'
IF EMPTY(OBJVAR())
KEYBOARD '{HOME}'
IF M.SELECTFIELD
KEYBOARD '{SHIFT+END}'
ENDIF
ELSE
IF M.SELECTFIELD
KEYBOARD '{HOME}'
KEYBOARD '{SHIFT+END}'
ELSE
KEYBOARD '{END}'
ENDIF
ENDIF
This trick will work regardless of whether you Mouse in, or Tab in. Note that this works on all Text Box data types as well. Numeric, Text, Logical, dosn't matter. I find it very useful, and it is in EVERY screenset I write now. Hope it helps you as well.
Well, I figure since I'm asking questions here, I might as well put up something that I think others might find handy. Ever notice the "Select Field On Entry" option in text boxes? Ever been anoyed by the fact that if you click on one with a mouse, it has NO effect whatsoever. This feature is only useful when "Tabbing" through fields. I have created the following function called ENTERFIELD, which will take control, regardless of how "Select Field On Entry" is set. (I did this because after I created the fuction, I didn't want to go back and change all my text boxes on every screen.)
How it works: In the WHEN clause, simply place in one of the following:
=ENTERFIELD()
or
=ENTERFIELD(.T.)
(Note that the first has the same effect if you put in =ENTERFIELD(.F.), but sometimes I'm lazy...)
The difference between the two is as follows:
Setting the .T. value will cause the text box to behave exactly as the "Select Field On Entry", regardless of how you get in there. Setting it with a .F. value, will automatically place the cursor at the END of the information in the box.
Then ensure the following code is in your procedure file (set with "SET PROCEDURE TO <procname>":
PROCEDURE ENTERFIELD
PARAMETER M.SELECTFIELD
IF PARAMETERS() = 0
M.SELECTFIELD = .F.
ENDIF
*
KEYBOARD '{SHIFT+RIGHTARROW}'
IF EMPTY(OBJVAR())
KEYBOARD '{HOME}'
IF M.SELECTFIELD
KEYBOARD '{SHIFT+END}'
ENDIF
ELSE
IF M.SELECTFIELD
KEYBOARD '{HOME}'
KEYBOARD '{SHIFT+END}'
ELSE
KEYBOARD '{END}'
ENDIF
ENDIF
This trick will work regardless of whether you Mouse in, or Tab in. Note that this works on all Text Box data types as well. Numeric, Text, Logical, dosn't matter. I find it very useful, and it is in EVERY screenset I write now. Hope it helps you as well.