Revision: 3621
http://vexi.svn.sourceforge.net/vexi/?rev=3621&view=rev
Author: clrg
Date: 2009-08-25 15:57:47 +0000 (Tue, 25 Aug 2009)
Log Message:
-----------
Fix focused puts in clickable/focusable actions not being honored
Modified Paths:
--------------
trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/focusable.t
trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/focusmanager.t
trunk/widgets/org.vexi.widgets/src_dev/visualtest/text.t
trunk/widgets/org.vexi.widgets/src_vunit/test/widget/numfield.t
Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/focusable.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/focusable.t
2009-08-24 21:28:40 UTC (rev 3620)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/focusable.t
2009-08-25 15:57:47 UTC (rev 3621)
@@ -71,36 +71,52 @@
/** write trap to set focused state */
static.focusedWrite = function(v) {
- cascade = trapee.v_focusmodel
- ? trapee.v_focusmodel.setFocus(trapee, v and trapee.focusable)
- : false;
+ var s = trapee.surface;
+ var focus = s ? s.focus : null;
+ if (focus==null) {
+ cascade = false;
+ } else {
+ var f = trapee.focusable;
+ if (f and v) focus.focusrequest = trapee;
+ cascade = focus.setFocus(trapee, f and v);
+ }
}
/** read trap to return the focus after trapee on the surface */
- static.nextfocusRead = function() { return
trapee.v_focusmodel.nextFocus(trapee); }
+ static.nextfocusRead = function() {
+ var s = trapee.surface;
+ return s and s.focus ? s.focus.nextFocus(trapee) : null;
+ }
/** read trap to return the focus before trapee on the surface */
- static.prevfocusRead = function() { return
trapee.v_focusmodel.prevFocus(trapee); }
+ static.prevfocusRead = function() {
+ var s = trapee.surface;
+ return s and s.focus ? s.focus.prevFocus(trapee) : null;
+ }
/** write trap to handle surface change */
static.surfaceWrite = function(v) {
// drop from current surface
var s = trapee.surface;
- if (s and s.focus)
+ if (s and s.focus) {
s.focus.dropFocus(trapee);
+ }
// add to new surface
if (v and v.focus) {
v.focus.addFocus(trapee);
- trapee.v_focusmodel = v.focus;
- } else trapee.v_focusmodel = null;
+ }
cascade = v;
}
/** write trap to focus on Press1 */
static.pressWrite = function(v) {
cascade = v;
- if (trapee.focusable and !trapee.v_focusmodel.focusrequest)
- trapee.v_focusmodel.focusrequest = trapee;
+ if (trapee.focusable) {
+ var s = trapee.surface;
+ if (s and s.focus and !s.focus.focusrequest) {
+ s.focus.focusrequest = trapee;
+ }
+ }
}
</vexi>
Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/focusmanager.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/focusmanager.t
2009-08-24 21:28:40 UTC (rev 3620)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/focusmanager.t
2009-08-25 15:57:47 UTC (rev 3621)
@@ -34,30 +34,33 @@
surface.frame.Focused ++= function(v) {
cascade = v;
if (focus) {
- if (surface.frame.Focused) focus.focused = true;
- else focus.focused = false;
+ if (surface.frame.Focused) {
+ focus.focused = true;
+ } else {
+ focus.focused = false;
+ }
}
}
/** set or unset a focused widget */
model.setFocus = function(v, f) {
- // focus
if (f and fvector.contains(v)) {
+ // focus
if (focus and focus != v) focus.focused = false;
focus = v;
model.current = v;
return true;
-
- // defocus
} else if (!f and focus == v) {
+ // defocus
if (surface.event.Focused) {
focus = null;
model.focus = null;
return false;
}
-
- // nothing to do
- } else return false;
+ } else {
+ // nothing to do
+ return false;
+ }
}
/** add a focus to the focus vector, optionally after w */
@@ -83,9 +86,10 @@
}
}
return fvector.remove(v);
+ } else {
+ // not a member of this surface's focus model
+ return false;
}
- // not a member of this surface's focus model
- else return false;
}
/** return the next-in-line for focus after v */
@@ -113,14 +117,25 @@
}
/** give the requested widget the focus */
- surface.event._Release1 ++= function(v) {
+ surface.event._Press1 ++= function(v) {
+ // clear focusrequest as it gets set by manual focused puts
+ model.focusrequest = null;
+ // pass event to rest of ui
cascade = v;
+ }
+
+ /** give the requested widget the focus */
+ surface.event.Press1 ++= function(v) {
+ // if a request for focus has been made, honor it
if (model.focusrequest) {
// focus but avoid repeat focusing
- if (!model.focusrequest.focused)
+ if (!model.focusrequest.focused) {
model.focusrequest.focused = true;
+ }
model.focusrequest = null;
}
+ // et fini
+ cascade = v;
}
//////// Key Event Handling ///////////////////////////////////
Modified: trunk/widgets/org.vexi.widgets/src_dev/visualtest/text.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src_dev/visualtest/text.t 2009-08-24
21:28:40 UTC (rev 3620)
+++ trunk/widgets/org.vexi.widgets/src_dev/visualtest/text.t 2009-08-25
15:57:47 UTC (rev 3621)
@@ -7,13 +7,19 @@
+ "123 12345 1.23 123.45";
</w:textarea>
<ui:box>
+ <w:button id="set" text="Set Focused" />
<w:button id="get" text="Get Cursor Index" />
<ui:box id="output" />
</ui:box>
$get.action ++= function(v) {
cascade = v;
$output.text = "Cursor position:
"+$edit.v_edit.getCursorCharIndex();
- }
+ };
+ $set.action ++= function(v) {
+ cascade = v;
+ $edit.focused = true;
+ };
+ $set.focused ++= function(v) { cascade = v; vexi.log.info(new
vexi.js.Exception("button focus: "+v)); };
vexi.ui.frame = thisbox;
</ui:box>
</vexi>
\ No newline at end of file
Modified: trunk/widgets/org.vexi.widgets/src_vunit/test/widget/numfield.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src_vunit/test/widget/numfield.t
2009-08-24 21:28:40 UTC (rev 3620)
+++ trunk/widgets/org.vexi.widgets/src_vunit/test/widget/numfield.t
2009-08-25 15:57:47 UTC (rev 3621)
@@ -24,17 +24,18 @@
b.number = 2;
assertEq("2.00",b.value);
- assertExceptionThrown(function(){b.value = "sausage";});
+ assertExceptionThrown(function() { b.value = "sausage"; });
/**
* test numfield focusable and
* basic keyboard interactions
*/
- var focusmodel = { setFocus:function(t, f){return true;} };
+ var focusmodel = { setFocus:function(t, f) { return true; } };
+ var fmsurface = { focus:focusmodel };
var b1 = .numfield(vexi.box);
b1.decimalPlaces = 2;
- b1.v_focusmodel = focusmodel;
+ b1.surface ++= function() { return fmsurface; }
b1.value = "1.00";
b1.focused = true;
assertEq(true,b1.v_edit.select);
@@ -50,7 +51,7 @@
*/
var b2 = .numfield(vexi.box);
- b2.v_focusmodel = focusmodel;
+ b2.surface ++= function() { return fmsurface; }
b2.decimalPlaces = 2;
b2.KeyPressed = "1";
b2.KeyPressed = ".";
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn