Solved

tabbing from one mask edit to another automatically

Posted on 1998-07-01
12
149 Views
Last Modified: 2010-04-04
the users of my application have to enter 2 numbers in two separate mask edit fields. These are numeric values. I would like the focus to jump to the second mask edit when the first one is filled with digits (sort of like the Windows 95 authentication code.
0
Comment
Question by:sharons
12 Comments
 
LVL 1

Expert Comment

by:michaue
ID: 1356879
Set the MaxLength property of MaskEdit1 (at design time) to the maximum number of digits you want entered into the field.

And on the OnKeyUp event of MaskEdit1 put the following code

if Length(MaskEdit1.Text) = MaskEdit1.MaxLength then
  MaskEdit2.SetFocus;
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356880
michaue, Did you check it?
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356881
Yes, Why?  :)
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 5

Expert Comment

by:ronit051397
ID: 1356882
michaue, Did you check it?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356883
michaue, Did you check it?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356884
Because if you put some mask then it's not working. Put the following mask:
MaskEdit1.EditMask:='!\(999\)000-0000);1;_'
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356885
Sorry, I didn't check it with the mask ....
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356886
Here's the sollution with mask edit characters included:

You have to declare a variable to hold the character count, and initialize it with the value of mask characters for which the user won't enter anything (like spaces etc)

You don't have to set the MaxLenght property when you add and EditMask to MaskEdit1, because it will put the value in as soos as you change the EditMask property.

Then in the KeyPress event of MaskEdit1 put the following code ...

Count := Count + 1;
if Count = MaskEdit1.MaxLenght then
  MaskEdit2.SetFocus;
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356887
But then if you are pressing the left arrow key, meaning going back, then the Count will not have the right value of the cursor position, so in this case it will not work properly.
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356888
Any suggestions ?
0
 
LVL 3

Accepted Solution

by:
vladika earned 50 total points
ID: 1356889
Try it

procedure TForm1.MaskEdit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if MaskEdit1.SelStart = MaskEdit1.MaxLength then MaskEdit2.SetFocus;
end;

0
 

Author Comment

by:sharons
ID: 1356890
It works great.  Thank you.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question