Anonymous avatar Anonymous committed 1e6e225

scalafied button

Comments (0)

Files changed (1)

src/main/scala/login/LoginDemo.scala

 
 import de.matthiasmann.twl.renderer.lwjgl.LWJGLRenderer
 import de.matthiasmann.twl.theme.ThemeManager
+import de.matthiasmann.twlscala.Button
+import de.matthiasmann.twlscala.ButtonClicked
 import de.matthiasmann.twlscala.DialogLayout
-import de.matthiasmann.twl.Button
+import de.matthiasmann.twlscala.Label
+import de.matthiasmann.twlscala.Widget
 import de.matthiasmann.twl.EditField
 import de.matthiasmann.twl.FPSCounter
 import de.matthiasmann.twl.GUI
-import de.matthiasmann.twl.Label
-import de.matthiasmann.twl.Widget
-import login.Implicits.fun2run
 
 object LoginDemo extends App {
   val demo = new LoginDemo
 }
 
 class LoginDemo extends Widget { root =>
+  theme = "logindemo"
+    
   import Implicits._
 
   var quit: Boolean = false
     lPassword.setLabelFor(efPassword)
 
     val btnLogin = new Button("LOGIN")
-    btnLogin.addCallback(emulateLogin _)
-
+    
     horizontalGroup = ((lName || lPassword) -- (efName || efPassword)) || (Filler -- btnLogin)
     verticalGroup = (lName || efName) -- (lPassword || efPassword) -- btnLogin
 
+    listenTo(btnLogin)
+    reactions += {
+      case ButtonClicked(`btnLogin`) => emulateLogin()
+    }
+    
     def emulateLogin() {
       val gui = getGUI
       if (gui != null) {
       getInnerX + (root.getInnerWidth - loginPanel.getWidth) / 2,
       getInnerY + (root.getInnerHeight - loginPanel.getHeight) / 2)
   }
-
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.