Sign in to follow this  
Rodney

Set a button to blink

Recommended Posts

Hi

I am trying to get a "Button" to blink under certain conditions but there is no StrBlink component variable for a button

I can get a Static text component to do it as it has the StrBlink component variable

The Button with its borders looks better than a static text box therefore I would like to use the "Button" component

I think it can do it by using  CreateStringProperty in the OnLoad event

But the actual syntax eludes me........

can it be done ? - if so what is the syntax

(ps have have a number of buttons on the same page I would like to do this with  - if it can be done -- do I need to place them in some kind of group to make this easier?)

Rodney

 

 

Share this post


Link to post
Share on other sites

Well, first, you can always create a button look by putting a panel behind some text (or an image!)

But what you want to do with the actual button control you can do in On Paint Event of the button.  Let's say you want it to blink each second if myVar is true.  In the Event put:

visible = !myVar || (systime() % 2 > 1)

Note that the page refresh rate will affect the quality of the blink.

The first part of the above simply says that the button should be visible if myVar is false (i.e. not flash).  If it is true, then the second part kicks in due to the OR.  % is modulus, meaning the remainder, and systime() % 2 is the remainder of dividing the current time by 2 seconds, so it will give a number between to 0 and 1.999999...  depending on the time.  I check if this result is > 1 which is half the time and results in an on for 1 second / off for 1 second.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this