Revision: 4211
          http://vexi.svn.sourceforge.net/vexi/?rev=4211&view=rev
Author:   clrg
Date:     2011-08-25 02:49:05 +0000 (Thu, 25 Aug 2011)
Log Message:
-----------
Refactor textarea to use only static/dynamic trap functions

Modified Paths:
--------------
    trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/textarea.t

Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/textarea.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/textarea.t 
2011-08-21 02:01:36 UTC (rev 4210)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/textarea.t 
2011-08-25 02:49:05 UTC (rev 4211)
@@ -1,4 +1,4 @@
-<!-- Copyright 2009 - see COPYING for details [LGPL] -->
+<!-- Copyright 2011 - see COPYING for details [LGPL] -->
 
 <vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="org.vexi.lib.role">
     <meta:doc>
@@ -18,18 +18,6 @@
         thisbox.value ++= static.valueWrite;
         thisbox.v_edit ++= static.v_editWrite;
         
-        /** syncs the view to be make sure the cursor is visible */
-        var syncViewWithCursor = function(v) {
-            cascade = v;
-            if (!th_scroll) return;
-            if (th_scroll.viewy > v)
-                th_scroll.viewy = v;
-            else if (v + trapee.height + 6 > th_scroll.viewheight + 
th_scroll.viewy)
-                th_scroll.viewy = v + 6 + trapee.height - th_scroll.viewheight;
-        }
-        
-        thisbox.v_cursor ++= function(v) { cascade = v; v.y ++= 
syncViewWithCursor; }
-        
     </ui:box>
     
     /** return text as value */
@@ -41,9 +29,6 @@
     /** pass on focus notification to editbox */
     static.enableWrite = function(v) { cascade = v; trapee.v_edit.enabled = 
trapee.enabled; }
     
-    /** pass on focus notification to editbox */
-    static.focusWrite = function(v) { cascade = v; trapee.v_edit.focused = 
trapee.focused; }
-    
     /** passon keypress to editbox */
     static.keypressWrite = function(v) { cascade = v; trapee.v_edit.KeyPressed 
= v; }
     
@@ -53,4 +38,35 @@
         v.multiline = true;
     }
     
+    /** pass on focus notification to editbox */
+    static.focusWrite = function(f) {
+        cascade = f;
+        var focused = trapee.focused;
+        trapee.v_edit.focused = focused;
+        
+        var cursor = trapee.v_cursor;
+        var scroll = trapee.th_scroll;
+        
+        if (focused and cursor!=null and scroll!=null) {
+            var targ = trapee;
+            
+               /** syncs the view to be make sure the cursor is visible */
+               var sync = function(v) {
+                   cascade = v;
+                   if (!scroll) return;
+                   if (scroll.viewy > v)
+                       scroll.viewy = v;
+                   else if (v + targ.height + 6 > scroll.viewheight + 
scroll.viewy)
+                       scroll.viewy = v + 6 + targ.height - scroll.viewheight;
+               }
+               // assign trap
+            cursor.y ++= sync;
+            // clean up trap
+            trapee.focused ++= function(v) {
+                cascade = v;
+                if (!v) cursor.y --= sync;
+            }
+        }
+    }
+    
 </vexi>

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to