Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select field On Entry - ENTERFIELD a useful trick

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,795
10
38
JP
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 &quot;SET PROCEDURE TO <procname>&quot;:

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.
 
Cute Idea, Thanks David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
Its good function but i use

@ 3,3 get field1 pict '@K'
READ

to select field.
 
In the same vein, ever notice that under certain conditions @...GET push buttons aren't highlighted (indicating which one gets activated when the ENTER key is pressed)? I've put this code in my screen &quot;READ CLAUSES WHEN&quot; which seems to fix it.
Code:
CLEAR TYPEAHEAD
KEYBOARD &quot;{tab}&quot;
WAIT &quot;&quot;
The WAIT &quot;eats&quot; the TAB, so nothing happens, except FPD thinks the last thing it's dealt with is a key stroke (not a mouse click), which seems to turn the button highlight on. Go figure.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top