K kavka Member Licensed User Dec 21, 2007 #1 Hello! Help me solve the following problem: I have two textboxes. The number of digits in one textbox is two. When I enter the second digit in the first textbox I want that the second textbox gets focused. is that possible? :sign0085: kavkaa
Hello! Help me solve the following problem: I have two textboxes. The number of digits in one textbox is two. When I enter the second digit in the first textbox I want that the second textbox gets focused. is that possible? :sign0085: kavkaa
W willisgt Active Member Licensed User Dec 21, 2007 #2 Sure, it's possible. The most logical thing to do would be to catch this with the KeyPress event. There's a problem, though - the KeyPress event gets raised *before* the key you pressed actually gets added to the textbox. At least that's the behavior on my desktop and device. So I've been using a little workaround that involves a timer. Create your form, textbox1, textbox2, and timer1. In AppStart: Code: timer1.interval = 100 ' thats 100 milliseconds timer1.enabled = false and then: Code: sub textbox1_KeyPress( key ) timer1.enabled = true end sub sub timer1_Tick if StrLength( textbox1.text) >= 2 then textbox2.Focus timer1.enabled = false end sub It comes close to a cheezy hack, but hey, it works for me. Gary :sign0025:
Sure, it's possible. The most logical thing to do would be to catch this with the KeyPress event. There's a problem, though - the KeyPress event gets raised *before* the key you pressed actually gets added to the textbox. At least that's the behavior on my desktop and device. So I've been using a little workaround that involves a timer. Create your form, textbox1, textbox2, and timer1. In AppStart: Code: timer1.interval = 100 ' thats 100 milliseconds timer1.enabled = false and then: Code: sub textbox1_KeyPress( key ) timer1.enabled = true end sub sub timer1_Tick if StrLength( textbox1.text) >= 2 then textbox2.Focus timer1.enabled = false end sub It comes close to a cheezy hack, but hey, it works for me. Gary :sign0025:
agraham Expert Licensed User Longtime User Dec 21, 2007 #3 You could use my ControlEvents library that adds "missing" events to B4PPC controls and catch the TextChanged event of the TextBox which occurs after the key press is added. Much better than cheesy hacks (Apologies willisgt!) http://www.b4x.com/forum/showthread.php?t=934
You could use my ControlEvents library that adds "missing" events to B4PPC controls and catch the TextChanged event of the TextBox which occurs after the key press is added. Much better than cheesy hacks (Apologies willisgt!) http://www.b4x.com/forum/showthread.php?t=934
W willisgt Active Member Licensed User Dec 21, 2007 #4 Cheezy hackers of the world, unite! :sign0151:
K kavka Member Licensed User Dec 22, 2007 #5 agraham, can you help me out with this missing events. Do I just copy those three files in the library directory and that is that?
agraham, can you help me out with this missing events. Do I just copy those three files in the library directory and that is that?
agraham Expert Licensed User Longtime User Dec 22, 2007 #6 Sounds like you need to learn how to use libraries. You should have downloaded the latest ControlEvents version from either Post #5 (.Net 2.0) or #6 (.NET1.0) from that thread. One of those files is a help file, the chm, the library is the dll - stick the help and the library in the Anywhere Software Libraries folder. Ignore and discard the cs file - you don't need it. Restart B4PPC - Desktop. The ControlEvents help should now show under Help - read it and the Main help about libraries.
Sounds like you need to learn how to use libraries. You should have downloaded the latest ControlEvents version from either Post #5 (.Net 2.0) or #6 (.NET1.0) from that thread. One of those files is a help file, the chm, the library is the dll - stick the help and the library in the Anywhere Software Libraries folder. Ignore and discard the cs file - you don't need it. Restart B4PPC - Desktop. The ControlEvents help should now show under Help - read it and the Main help about libraries.