We have barcode scanners that we're using to scan an item from a combo box. What we do is, in the KeyDown event, we check for a tab key (or enter key, as some scanners use that) and then we check to see if the text in the combo matches an item. If it does, then what we want to do is clear out the combo's textbox, close the dropdown, and keep the focus inside the combo.
Specifically, what I'm doing at the end of my code is:
warehouseItemCombo.igCombo('text', '', false); warehouseItemCombo.igCombo('setFocus'); e.stopImmediatePropagation(); e.preventDefault();
The problem is, my combo remains open (dropped down) with the item that matches the scanned barcode in the textbox, and I can't really figure out where the focus is, but it doesn't appear to be in teh combo.
How can I make this work the way I want? Incidentally, this all works fine with just the enter key. It's with the tab key that the behavior is problematic.
Pete,
When the user scans an item and then proceeds to press the tab key, what action is it that you want from the tab key, prior to then checking if the text in the combo matches the item? So, what is the purpose of the TAB (or ENTER) key?
Thanks,
Troy,
The code above is what I'm doing in the keydown. I'm aware of what's happening. You say, "What you will need to do is change the behavior of the tab key when handling keydown, for the behavior you need for it to have." Yes, that's exactly what I'm asking you, is how to do that. How do I change the way the tab key is handled and not get the side effects I noted?
Pete
Hi Pete,
When you are checking for the tab key in the keydown event, what are you then doing with a tab key press? The default behavior of the tab key is to take focus from the current element and tab over to the 'next' element of the page, whichever that is. This will explain why you are finding that the focus as shifted away from the igCombo.
What you will need to do is change the behavior of the tab key when handling keydown, for the behavior you need for it to have.