Hackers Guide to Visual FoxPro 7.0
Click, RightClick, MiddleClick, DblClick
These events let you do something when the user clicks or double-clicks on an object. They also fire under a bunch of other circumstances. The Click method is likely to contain code more often than almost any other, especially for button objects.| Usage | PROCEDURE oObject.Click | oObject.RightClick | oObject.MiddleClick | oObject.DblClick [ LPARAMETERS nIndex ] |
| | In VFP 5 and VFP 6, clicking on the current page of a page frame in an area containing no control fires just the page's Click, while clicking on the tab of a page sometimes fires first the page frame's Click, then the form's Click, and finally the page's Click. In VFP 3, the sequence is the same, except that, in the second case, the form's Click doesn't fire. We can't see any reason why the form's Click fires. This bug appears to be fixed in VFP 7. |
Clicking the mouse is not a single event. Before Click fires, both MouseDown and MouseUp fire. You can usually prevent Click events from occurring by putting NoDefault in MouseUp.
| | Putting NoDefault in MouseUp doesn't prevent the Click events in Grids or Headers. We see different behavior in different versions as to what events NoDefault prevents in what controls. On the whole, we think a NoDefault in either MouseUp or MouseDown should prevent all the Click events from firing in every control, and we're sure not seeing that. |
If you want to be sure you're suppressing a particular Click event, test your specific case.
RightClick is important mostly for attaching context menus (also known as shortcut menus or right-click menus) to objects. MiddleClick was added in VFP 5 to accommodate three-button mouses (mice? rodents?). The introduction of Microsoft's IntelliMouse gave us a chance to test this one out—the mouse wheel can be pressed to produce a middle-click. In general, it's best not to assume that your users have a middle-button-capable device unless you're coding for a very small, well-known audience. (Of course, in general, it's not a good idea to assume that users have a mouse. We've all had the experience of working on a machine with a dead mouse. The best applications let us work anyway.)| Example | * Typical Click code processes the user's action. * A command button labeled Save might have: ThisForm.SaveRecord() |
| See Also | Mouse, MouseDown, MouseEnter, MouseLeave, MouseUp, MouseWheel, _DblClick |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.
Категории