FalconDEW Posted April 5, 2004 Posted April 5, 2004 I have a form with several buttons on it, and I created a typical case select function to handle keypress events. In order to get the keypresses to be picked up when I ran the program, I added a handler for form1.keypress and pointed it to my function. I soon found out that if I clicked on any button on the form, keypress events would break... so I ended up adding handlers for every button (button1.keypres, etc) and pointed them all the the keypress case select function as well. I'm wondering if there's a different way to handle this? As I continued to create my program... the handlers I added for each button.keypress broke, because keypresses when a button is selected are not being picked up. I'm hoping there's a better way. Any help would be appreciated! Quote
Roey Posted April 6, 2004 Posted April 6, 2004 Try having a look at using the AddHandler keyword: AddHandler Button1.Click, AddressOf ClickHandler Hope this helps.... Quote
FalconDEW Posted April 6, 2004 Author Posted April 6, 2004 Already using that... I'm already doing that. What I was trying to say up above, is that while I already have handlers in place for the btn.keypresses, along with the form.keypress, if I disable the button after it's been clicked on... it seems that neither the form or the button has focus - so I can't find a way to catch keypresses any more after than. I guess what I'm looking for is a universal way to catch keypresses, regardless of focus... or a way to change the focus back to the main form (which I could then use at the end of any button click action). -Falcon Quote
Administrators PlausiblyDamp Posted April 6, 2004 Administrators Posted April 6, 2004 Set the form's KeyPreview property to true and it should work. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.