Question

First of all, sorry for the generic title, I didn't know who to write my question.

I'm in a trouble, i'm trying to create a control but I don't know how to do it. Here is what I would like to do:

I created a chronometer (just an int that increase 1 by 1) and I want to write that: If clickNumber == 1 and the chronometer is less than 144, wait until it reach this number, if it is 144, then make and action, then exactly the same, if clickNumber == 2 and the chronometer is less than 72, wait until it reach this number, if the chronometer is == 72 then make and action.

I think it might be so easy to do, but I can't see how to do it.

Thank you all

Était-ce utile?

La solution

Your issue is better thought in terms of events and objects.

Let's say you have a Chronometer and it has at least three parts: Display, button and code. The display will show the value of the chronometer. The button will behave as you describe. The code is the part that manages everything.

Your chronometer code will be receiving events from at least two sources: Timer and Button. The timer is a system time that sends you message periodically (like once a second). The button will send your chronometer code an event when the user clicks on the button.

So you will need to have some static variables to hold your information.

You will need to think in terms of the event:

if event == button click
   then increment click and check click count.
endif

if event == timer
   then
      increment chronometer value.
      if chronometer value == limit, then stop the timer.
endif

The implementation of the algorithm depends on the GUI framework you are using.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top