GTKD - CSS class color "flash" delay
Mike Wey via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 26 05:30:22 PDT 2016
On 06/26/2016 12:10 AM, TheDGuy wrote:
> On Saturday, 25 June 2016 at 21:57:35 UTC, TheDGuy wrote:
>> But i want to flash (e.g. change the CSS class) the buttons one by one
>> and not all at the sime time? How am i going to do that?
>
> Okay, i tried it with a new private int-variable which contains the
> current index of the for-loop, like this:
>
> private void letButtonsFlash(){
> foreach(Button btn;bArr){
> btn.setSensitive(false);
> }
> for(int i = 0; i < level; i++){
> index = i; //index is public
> Button currentButton = bArr[rndButtonBlink[i]];
> ListG list = currentButton.getStyleContext().listClasses();
> string CSSClassName = to!string(cast(char*)list.next().data);
> currentButton.getStyleContext().addClass(CSSClassName ~
> "-flash");
> Timeout t = new Timeout(&timeout_delay,1,false);
> }
>
> foreach(Button btn;bArr){
> btn.setSensitive(true);
> }
> }
> bool timeout_delay(){
> Button currentButton = bArr[rndButtonBlink[index]];
> ListG list = currentButton.getStyleContext().listClasses();
> string CSSClassName = to!string(cast(char*)list.next().data);
> currentButton.getStyleContext().removeClass(CSSClassName ~
> "-flash");
> return false;
> }
>
> But now the strange thing happens, that the first button lights up as
> expected but the second button remains at its "flash color" and doesn't
> go back to normal color, i don't understand why this happens? Any ideas?
You should probably increment the index in the timeout_delay function.
--
Mike Wey
More information about the Digitalmars-d-learn
mailing list