GTKD - CSS class color "flash" delay

TheDGuy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 24 13:03:36 PDT 2016


On Friday, 24 June 2016 at 16:44:59 UTC, Gerald wrote:
> Other then the obvious multi-threaded, using glib.Timeout to 
> trigger the reversion of the color change could be an option.
>
> http://api.gtkd.org/src/glib/Timeout.html

Thanks! I tried this so far:
     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");
             writeln(CSSClassName);
             Timeout t = new Timeout(&timeout_delay,1,true);
             
currentButton.getStyleContext().removeClass(CSSClassName ~ 
"-flash");

         }
         foreach(Button btn;bArr){
             btn.setSensitive(true);
         }
     }
     bool timeout_delay(){
         Thread.sleep(dur!("seconds")(5));
         return false;
     }

and it is "working" to the extend that at least the CSSClassName 
gets written in the console but the UI again just pops up after 5 
sec. Could you give me a tip?


More information about the Digitalmars-d-learn mailing list