Hi Tom,
On 06/06/2009, at 2:18 AM, Thomas Fitch wrote:
> The method I suggested isn't going to work with a button. I do have
> another
> suggestion though... use a picture variable. :-)
>
>
> I outline it in this tech tip:
>
>
http://kb.4d.com/search/assetid=75706>
> The tech tip discusses how to implement drag and drop in SVG images
> but you
> can use the same idea to implement a speed counter. Use the Mouse
> Enter,
> Mouse Leave, and On Clicked events of the picture variable to manage
> the
> Timer and then handle the incrementing via the On Time form event.
I couldn't get your second suggestion to work either.
However, looking up Form events I came across this ...
For all these objects, the On Clicked event occurs once the mouse
button is released. However, there are several exceptions:
• Invisible buttons - The On Clicked event occurs as soon as the click
is made and does not wait for the mouse button to be released.
Remembering your earlier comments, I tried invisible buttons and with
a few adjustments, I was able to get it to work!
Thanks for your input and suggestions, it gave me all the clues I
needed and learnt heaps.
Michael.
PS. Here's the code I used.
Invisible button Object Method code ...
: (Form event=On Clicked )
UserButtonDown:=True
SET TIMER(10)
If (vn_CareTime=20)
DISABLE BUTTON(bi_UpTime)
SET TIMER(0)
Else
vn_CareTime:=vn_CareTime+0.25
ENABLE BUTTON(bi_DownTime)
End if
Form Method Code ...
: (Form event=On Load )
C_LONGINT(iCnt)
C_LONGINT($x;$y;$MouseState) `// not used, but needed for On Timer
event below
C_BOOLEAN(UserButtonDown)
UserButtonDown:=False
iCnt:=0
: (Form event=On Timer )
GET MOUSE($x;$y;$MouseState) `// get mouse state
If (($MouseState=1) & (UserButtonDown)) `// 1 = mouse button down
If (vn_CareTime=20)
SET TIMER(0)
UserButtonDown:=False
iCnt:=0
Else
iCnt:=iCnt+1
vn_CareTime:=vn_CareTime+0.25
Case of
: (iCnt>20) `// go very fast
SET TIMER(2)
: (iCnt>5) `// go faster
SET TIMER(15)
: (iCnt<5) `// go slowly
SET TIMER(25)
End case
End if
Else
SET TIMER(0)
UserButtonDown:=False
iCnt:=0
End if
**********************************************************************
4D Basics hosted by 4D, Inc.
http://www.4D.com/Register for 4D Summit 2009 Today
Early Bird Pricing Ends August 28th -
http://www.4D.com/summitTo Unsubscribe: mailto:
4DBasics-off@...
**********************************************************************