#1054 print log in UI

Akcelisto Fri 2 Apr 2010

using fwt

class Main : Window{

  new make():super(){
    btn := Button{
      text = "log"
      onAction.add|e|{
        Log.get("log").info("I log")
      }
    }
    console := Text{
      multiLine = true
    }      
    Log.addHandler|rec|{
      console.text = console.text + rec.msg
    } 
    content = GridPane{
      btn, console
    }
  }

  static Void main(){
    Main().open
  }
}

Throws:

sys::NotImmutableErr: handler must be immutable

How to write this properly?

Akcelisto Fri 2 Apr 2010

I read clock example. Now it works.

using fwt

class Main : Window{  
  new make():super(){
    btn := Button{
      text = "log"
      onAction.add|e|{
        Log.get("log").info("I log")
      }
    }
    console := Text{
      multiLine = true
    }
    Actor.locals["console"] = console
    Log.addHandler|rec|{
      Desktop.callAsync |->| { 
        c := (Text)Actor.locals["console"]
        c.text = c.text + rec.msg + "\r\n"
      }        
    } 
    content = GridPane{
      btn, console
    }
  }

  static Void main(){
    Main().open
  }
}

Login or Signup to reply.