Revision: 4207
          http://vexi.svn.sourceforge.net/vexi/?rev=4207&view=rev
Author:   clrg
Date:     2011-08-17 04:47:44 +0000 (Wed, 17 Aug 2011)

Log Message:
-----------
Clean up and fix cursor going off visual range of the field

Modified Paths:
--------------
    trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/field.t

Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/field.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/field.t      
2011-08-17 04:41:02 UTC (rev 4206)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/text/field.t      
2011-08-17 04:47:44 UTC (rev 4207)
@@ -1,11 +1,8 @@
 <!-- Copyright 2011 - see COPYING for details [LGPL] -->
 
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns:rdt="vexi.util.redirect">
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta">
     <meta:doc>
         <author>Charles Goodwin</author>
-        <todo>
-            Need value write trap - cannot specify a password e.g. $pwd.value 
= "foo"
-        </todo>
     </meta:doc>
     
     <ui:box>
@@ -127,6 +124,9 @@
         var edit = trapee.v_edit;
         var cursor = trapee.v_cursor;
         var f = trapee.focused;
+        var tbox = trapee;
+        var view = tbox.th_view;
+        var viewport = tbox.th_viewport;
         
         edit.focused = f;
         if (f) {
@@ -135,11 +135,8 @@
             }
             
             // sync the textfield with the cursor pos so it is always visible
-            var tbox = trapee;
             var sync = function(v) {
                 cascade = v;
-                var view = tbox.th_view;
-                var viewport = tbox.th_viewport;
                 var viewtoedit   = view.distanceto(edit).x;
                 var porttocursor = viewport.distanceto(cursor).x;
                 var vieweditend  = view.width - edit.width - viewtoedit;
@@ -152,9 +149,9 @@
                     // cursor too far to the left
                     view.x = -cursor.x;
                     
-                } else if (porttocursor + cursor.width > viewport.width) {
+                } else if (porttocursor + cursor.width > viewport.width - 
tbox.paddingright) {
                     // cursor too far to the right
-                    view.x = viewport.width - vieweditend - cursor.x - 
viewtoedit;
+                    view.x = viewport.width - tbox.paddingright - vieweditend 
- cursor.x - viewtoedit;
                     
                 } else if (0 > view.x and viewport.width > view.width + 
view.x) {
                     // cursor visible but view is too far to the left 
@@ -165,7 +162,7 @@
             tbox.v_syncViewWithCursor = v_sync;
             if (cursor and sync) {
                 cursor.x ++= sync;
-                trapee.th_viewport.width ++= sync;
+                viewport.width ++= sync;
             }
         } else {
             if (trapee.selectonfocus) {
@@ -175,8 +172,8 @@
             trapee.v_syncViewWithCursor = null;
             if (cursor and sync) {
                 cursor.x --= sync;
-                trapee.th_view.width --= sync;
-                trapee.th_viewport.width --= sync;
+                view.width --= sync;
+                viewport.width --= sync;
             }
         }
     }


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

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to