[Lazarus] Purpose of MouseCapture?

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sun Jan 9 15:27:16 CET 2011


Graeme Geldenhuys schrieb:
> On 8 January 2011 17:16, Hans-Peter Diettrich <DrDiettrich1 at aol.com> wrote:
>>> What's the purpose of setting the mouse capture in the LCL?
>> While nobody seems to know, I found that TSpltter uses mouse capture.
> 
> MouseCapture (at least under fpGUI) is also used while the mouse
> button is down, eg on a TButton. For example (i think this works under
> LCL too). Click a TButton, and hold the mouse button down. Now move
> the mouse cursor outside the TButton bounds. The TButton should pop up
> (normal state again), and when you hove the mouse over the TButton,
> the mouse would be pressed again.

That's questionable behaviour, that must be checked for compatibility 
with e.g. an DragManager.

Since a DragManager has no HWND and cannot capture the mouse itself, a 
safe implementation would redirect all mouse and keyboard events to an 
dragging DragManager immediately, instead of delivering the events to 
the target control, in the hope that it will *in any case* forward the 
messages to the DragManager.

At least I observed some weird behaviour of some controls, that do not 
check properly for a drag operation in progress. No such checks are 
required, and can be forgotten or implemented in a wrong way, when the 
event dispatcher already checks for a dragging operation in progress.

DoDi





More information about the Lazarus mailing list