Page 1 of 1

Auto-Tab to next text box after input

Posted: Tue Feb 26, 2013 5:23 am
by graves
Hello,

I want to build a small form used to collect three barcodes from a handheld scanner to three separate fields. Is there any way to auto-tab to the next field after scanning a barcode so the user doesn't have to manually tab to the next field before scanning again? In the mean time I designed it so that all the data is scanned into a rich text box in a specific order, the data get's stored to a variable and split by `n`r where a for loop counts through every three strings and creates a log file with the data. However, I'm just not happy with this from a end user perspective as three separate labeled fields would be more intuitive.

Thanks

Auto-Tab to next text box after input

Posted: Tue Feb 26, 2013 5:31 am
by Alexander Riedel
Use the .Focus() member of whatever control object you want to have the input focus after processing the change event from the previous input.

Auto-Tab to next text box after input

Posted: Tue Feb 26, 2013 8:14 am
by graves
Thanks, Alexander! Works perfectly.

$txtBoxA
$txtBoxB

$handler_txtBoxA_TextChanged=
{
if ($txtBoxA.Text.Length -ge 7)
{
$txtBoxB.Focus()
}
}

Auto-Tab to next text box after input

Posted: Wed Feb 27, 2013 5:03 am
by graves
One question though - what if I don't know the length of the field? The problem I'm running up against is obviously if $txtBoxA.Text.Length is greater than 7, the cursor is jumping to the next field after 7 characters are entered.

This field is used to collect hard drive serial numbers and the length varies quite often amongst different manufacturers and models.

Any suggestions?

Thanks in advance.

Auto-Tab to next text box after input

Posted: Wed Feb 27, 2013 6:01 am
by davidc
If the length is unknown they you should not change the focus on the control and let the user decide.

I recommend setting the tab order of the controls, so when the user presses the 'Tab' key, it will jump to the next field. The tab order button is located:

Ribbon->Home->Designer

Once you press the tab order button, simply click on the controls and it will set the tab index in the order of your clicks.

David

Auto-Tab to next text box after input

Posted: Wed Feb 27, 2013 6:32 am
by graves
Thanks for your reply but the only problem with that is the user may or may not be near a keyboard as they are using a wireless handheld scanner and are often not near the workstation.

I really hope I don't have to abandon this layout for my previous one.

Thanks,
Jason

Auto-Tab to next text box after input

Posted: Wed Feb 27, 2013 8:18 am
by davidc
So the user isn't typing the value in? Can't you just focus the control after inserting the value? I guess I'm not clear on what is happening here.

David

Auto-Tab to next text box after input

Posted: Wed Feb 27, 2013 9:18 am
by graves
Seems I might be missing something very basic here. I would like to simply focus the control after the user scans the data but I don't know how without using a TextChanged event on the control and if the length of the string is not consistent then TextChanged does me no good.

The process should go like:

-user scans data to field 1.
-focus automatically changes to field 2.
-user scans data to field 2
-focus changes to field 3
-user scans data to field 3
-the submit button automatically is pressed (will probably hide the submit button control)
-data from all three fields is stored to separate variables and a log is created with the data
-all fields are cleared and focus is reset to field 1.

I have this all working using TextChanged but not without a huge drawback of not always knowing the string length.

Thanks,
Jason

Auto-Tab to next text box after input

Posted: Wed Feb 27, 2013 9:52 am
by davidc
You don't have to use the TextChanged event if your script is inserting the text. It is hard to tell what you are doing without looking at the script.

This really is going beyond the scope of this product forum. I recommend posting the question in the Windows PowerShell forum and include a sample form.

David