Subject Re: Programmatically Adding An Event
From <> <<>>
Date Wed, 5 Dec 2018 11:04:37 -0500
Newsgroups dbase.getting-started
Attachment(s) demo2b.wfm

I took the liberty of taking the demo2b.wfm and altering it along the lines
of the WhileMouseDown functionality.
I stripped most everything out of the form and just left the controls and a
new downbutton function.
I'll leave it up to whoever want to experiment with it to add more
When either button is pushed it will add or subtract 1 to the value. If held
down it will repeat adding or subtracting 1 to the value.
The repeat speed is slowed down by using sleep so you can adjust how fast it
I pulled the routine out of one of my controls that simulates a spinbox but
I also use it to scroll though a table.

"Tom"  wrote in message news:O8yEiBLjUHA.1352@ip-AC1E04A7...

On 12/4/18 5:02 PM, Ronnie MacGregor wrote:
> In article <5GsYlxAjUHA.904@ip-AC1E04A7>, invalid@invalid.invald says...
>> Hold
>> the left mouse button down and the entryfield updates continuously.
>   I wonder if you remember my "WhileMouseDown" functionality for
> Jean-Pierre's CD Player (dBulletin)
Issue 17 for anyone else interested ...

The WhileMouseDown Class

When the left mouse button is pushed and held down over an object, the
latter’s onLeftMouseDown() event is fired only once.  If we want an
action to be repeated while a button is pushed, we could create a loop
in its onLeftMouseDown() event and break that loop when the mouse is
released.  However, that solution is hazardous:  if the mouse is dragged
outside the surface of the button and then released over another object,
we could end up with an infinite loop.

For dBL developers, the real solution is to use a free component
designed by Romain Strieff and Ronnie MacGregor:  their WhileMouseDown
class.  This object does use a loop.  However, in that loop an API call
is made to check if the mouse button is still pushed over the button:
if it is not, the loop is broken from within the onLeftMouseDown() code,
thus preventing the hazardous situation we’ve just spoken about.

Being a visual component, this class can be made available from the
Component palette, and then can be drag’n dropped onto a form under the
Form designer.