GTKD - CSS class color "flash" delay

Mike Wey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 26 09:29:52 PDT 2016


On 06/26/2016 05:03 PM, TheDGuy wrote:
> On Sunday, 26 June 2016 at 12:30:22 UTC, Mike Wey wrote:
>>
>> You should probably increment the index in the timeout_delay function.
>
> This leads to a Range violation exception...

How about this:

private void letButtonsFlash(){
     foreach(Button btn;bArr){
         btn.setSensitive(false);
     }
     for(int i = 0; i < level; i++){
         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);
}

bool timeout_delay(){
     for(int i = 0; i < level; i++){
         Button currentButton = bArr[rndButtonBlink[i]];
         ListG list = currentButton.getStyleContext().listClasses();
         string CSSClassName = to!string(cast(char*)list.next().data);
         currentButton.getStyleContext().removeClass(CSSClassName ~ 
"-flash");
     }
     foreach(Button btn;bArr){
         btn.setSensitive(true);
     }
     return false;
}

Sets all the buttons to the flash color and after an timeout removes the 
flash color from all the buttons.

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list