right click causes focus to go to another control
Posted on 1999-11-07
I suspect the solution to this falls under the category of reformat your disk, reinstall everything, then get a new computer. I have WIN 98, vb 6, sp 3, 64 mb Ram.
Don't bother trying to re-create this - it used to work fine and I'm sure it will work fine in your code.
Here's the problem:
I have a text box (plus other controls) where I have a mouseup event handler where I test for right button and then popup a context menu if it was.
This worked fine until I made a lot of changes in another part of the form.
Then what would happen is if I right clicked on the text box, instead of the context menu, focus would transfer to another text box.
I tried closing vb, reboot, build EXE and run that, all give same behavior.
I then made a copy of the text box which was getting the focus, deleted the original text box, and gave the new textbox the name of the one I deleted.
Now instead of that textbox getting the focus on rightclick, a command button got the focus.
I noticed that the command button had tabindex one higher than the textbox I was right clicking on - I changed tabindexes which resulted in different controls getting the focus (the next control in tab order would get it).
I copied the textbox with mouseup handler, gave the copy the original name and deleted the original. I still have the problem.
If I don't right click there is no problem (Yes, I know; I can solve the problem by instructing the user not to right click and if I get any complaints about weird behavior with right clicking, I can sneer and ask "don't you read the documentation?").
I guess the next step is to reinstall VB (after deleting it - as I've read here on EE).