Anonymous avatar Anonymous committed 184217f

added EditField into twlext

Comments (0)

Files changed (2)

src/main/scala/login/LoginDemo.scala

 import de.matthiasmann.twlscala.DialogLayout
 import de.matthiasmann.twlscala.Label
 import de.matthiasmann.twlscala.Widget
-import de.matthiasmann.twl.EditField
+import twlext.EditField
+import twlext.EditFieldChanged
 import de.matthiasmann.twl.FPSCounter
 import de.matthiasmann.twl.GUI
 
     verticalGroup = (lName || efName) -- (lPassword || efPassword) -- (lKeyVal || btnLogin)
 
     listenTo(btnLogin)
+    listenTo(efName)
+
     reactions += {
-      case ButtonClicked(`btnLogin`) => emulateLogin()
+      case ButtonClicked(`btnLogin`)       => emulateLogin()
+      case EditFieldChanged(`efName`, key) => { lKeyVal.text = "Key code: " + key }
     }
 
-    efName.addCallback(new EditField.Callback { 
-      def callback(key: Int) { lKeyVal.text = "Key code: " + key }})
-    
+    //    efName.addCallback(new EditField.Callback { 
+    //      def callback(key: Int) { lKeyVal.text = "Key code: " + key }})
+
     def emulateLogin() {
       // disable all controls while we're "logging in"
       efName.setEnabled(false)

src/main/scala/twlext/EditField.scala

+package twlext
+import de.matthiasmann.twlscala.twlinternal.ThemeSupport
+import de.matthiasmann.twlscala.Publisher
+
+import de.matthiasmann.twl.{ EditField => TWLEditField }
+
+case class EditFieldChanged(field: EditField, key: Int)
+
+
+class EditField extends TWLEditField with Publisher with ThemeSupport { self =>
+  addCallback(new TWLEditField.Callback {
+    def callback(key: Int) {
+      publish(EditFieldChanged(self, key))
+    }
+  })
+}
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.