Revision: 1768
http://svn.sourceforge.net/vexi/?rev=1768&view=rev
Author: clrg
Date: 2007-03-29 11:40:22 -0700 (Thu, 29 Mar 2007)
Log Message:
-----------
Slightly better textfield selection when mouse is outside textfield
Modified Paths:
--------------
widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/edit.t
Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/edit.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/edit.t 2007-03-29
18:21:47 UTC (rev 1767)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/edit.t 2007-03-29
18:40:22 UTC (rev 1768)
@@ -709,67 +709,57 @@
}
// else working within the current block
- // search for new position in multiline block
- if (multiline)
+ // empty block
+ if (aBlock.numchildren == 0)
{
- // empty block
- if (aBlock.numchildren == 0)
+ aWord = null;
+ aPos = 0;
+ }
+ // block with children
+ else
+ {
+ var ind1 = 0;
+ var ind2 = aBlock.numchildren-1;
+ var indm = 0;
+ while (ind2 > ind1)
{
- aWord = null;
- aPos = 0;
- }
- // block with children
- else
- {
- var ind1 = 0;
- var ind2 = aBlock.numchildren-1;
- var indm = 0;
- while (ind2 > ind1)
+ // the middle
+ indm = vexi.math.floor(ind1+(ind2-ind1)/2);
+ // indm is on a line below mouse click
+ if (aY > aBlock[indm].y+aBlock[indm].height)
{
- // the middle
- indm = vexi.math.floor(ind1+(ind2-ind1)/2);
- // indm is on a line below mouse click
- if (aY > aBlock[indm].y+aBlock[indm].height)
- {
- if (ind1 == indm) indm = ind2;
- ind1 = indm;
- continue;
- }
- // indm is on a line above mouse click
- if (aBlock[indm].y > aY)
- {
- if (ind2 == indm) indm = ind1;
- ind2 = indm;
- continue;
- }
- // indm is on the same line that was clicked
- break;
+ if (ind1 == indm) indm = ind2;
+ ind1 = indm;
+ continue;
}
- // to the right of current line, find word at the
end of the line
- if (aX > dX)
+ // indm is on a line above mouse click
+ if (aBlock[indm].y > aY)
{
- var n = aBlock.numchildren;
- while (n > indm+1 and aBlock[indm].y ==
aBlock[indm+1].y)
- indm++;
- aWord = aBlock[indm];
- aPos = aWord ? aWord.text.length : 0;
+ if (ind2 == indm) indm = ind1;
+ ind2 = indm;
+ continue;
}
- // to the left, find word at the start of the line
- else
- {
- while (indm-1 >= 0 and aBlock[indm].y ==
aBlock[indm-1].y)
- indm--;
- aWord = aBlock[indm];
- aPos = 0;
- }
+ // indm is on the same line that was clicked
+ break;
}
+ // to the right of current line, find word at the end
of the line
+ if (aX > dX)
+ {
+ var n = aBlock.numchildren;
+ while (n > indm+1 and aBlock[indm].y ==
aBlock[indm+1].y)
+ indm++;
+ aWord = aBlock[indm];
+ aPos = aWord ? aWord.text.length : 0;
+ }
+ // to the left, find word at the start of the line
+ else
+ {
+ while (indm-1 >= 0 and aBlock[indm].y ==
aBlock[indm-1].y)
+ indm--;
+ aWord = aBlock[indm];
+ aPos = 0;
+ }
}
- // single line edit
- else
- {
- aWord = aBlock.numchildren ?
aBlock[aBlock.numchildren-1] : null;
- aPos = aWord ? aWord.text.length : 0;
- }
break;
}
// FEATURE: syncCursor should probably happen post-highlight ?
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn