Author: pbr Date: 2007-07-19 14:19:22 -0700 (Thu, 19 Jul 2007) New Revision: 5717
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzFocus.lzs openlaszlo/branches/legals/WEB-INF/lps/lfc/services/platform/swf/LzModeManager.as openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloView.lzs Log: Change 20070719-Philip-4 by [EMAIL PROTECTED] on 2007-07-19 14:05:35 EST in /cygdrive/f/laszlo/svn/src/svn/openlaszlo/branches/legals for http://svn.openlaszlo.org/openlaszlo/branches/legals Summary: SWF: Text size and position available during onblur New Features: Bugs Fixed: LPP-4015 Technical Reviewer: max QA Reviewer: (pending) Doc Reviewer: (pending) Documentation: Release Notes: Details: LzFocus.lzx For the view losing focus, calls preBlur() before the focus change begins, and calls postBlur() after the focus has changed. LaszloView.lzx Defined preBlur() and postBlur() methods which are called from LzFocus() at the start and end of changing focus from one view to another. The default behavior is to set a variable, blurring to true when a view is losing focus. LzModeManager.as rawMouseEvent() caches the current selection (for all text views). LzTextSprite.as Defines _cacheSelection() method for the TextField object to capture the position and size of the selection. Modified getSelectionPosition() and getSelectionSize() to return the cached values if the view is losing focus. LzInputTextSprite.as Setup cacheSelection method to capture the position and size of selection. Tests: See the test case I posted in LPP-4015. When you click the button, the selection information from the input box (assuming it had focus) is displayed in the debu gger. Files: M WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as M WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as M WEB-INF/lps/lfc/services/platform/swf/LzModeManager.as M WEB-INF/lps/lfc/services/LzFocus.lzs M WEB-INF/lps/lfc/views/LaszloView.lzs Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20070719-Philip-4.tar Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as =================================================================== --- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as 2007-07-19 20:44:38 UTC (rev 5716) +++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as 2007-07-19 21:19:22 UTC (rev 5717) @@ -169,6 +169,7 @@ // set a pointer back to this view from the TextField object this.__LZtextclip.__lzview = this.owner; + this.__LZtextclip.__cacheSelection = TextField.prototype.__cacheSelection; textclip.onSetFocus = TextField.prototype.__gotFocus; textclip.onKillFocus = TextField.prototype.__lostFocus; textclip.onChanged = TextField.prototype.__onChanged; Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as =================================================================== --- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as 2007-07-19 20:44:38 UTC (rev 5716) +++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as 2007-07-19 21:19:22 UTC (rev 5717) @@ -43,6 +43,7 @@ this.__LZtextclip = textclip; // set a pointer back to this view from the TextField object this.__LZtextclip.__lzview = this.owner; + this.__LZtextclip.__cacheSelection = TextField.prototype.__cacheSelection; textclip._visible = true; textclip.__control = this; @@ -143,9 +144,24 @@ return this.__LZtextclip; } + /** + * Save a copy of the current selection position/size. This is called + * from LzModeManager.rawMouseEvent. This function is needed because + * the Selection object changes when the focus moves. By caching the + * position, getSelectionPosition() and getSelectionSize() works during + * this transition. * @access private */ +TextField.prototype.__cacheSelection = function () { + this.__cacheSelectionPos = Selection.getBeginIndex(); + this.__cacheSelectionSize = Selection.getEndIndex() - Selection.getBeginIndex(); +} + + +/** + * @access private + */ LzTextSprite.prototype.scroll = 0; /** * @access private @@ -890,6 +906,13 @@ LzTextSprite.prototype.getSelectionPosition = function ( ){ var sf = targetPath( this.__LZtextclip) ; if( Selection.getFocus() != sf ) { + var tc = this.__LZtextclip; + var v = tc.__lzview; + // Use cached values if available + if (v.blurring && tc.__cacheSelectionPos) { + return tc.__cacheSelectionPos; + } + return -1; } return Selection.getBeginIndex(); @@ -905,6 +928,13 @@ LzTextSprite.prototype.getSelectionSize = function ( ){ var sf = targetPath( this.__LZtextclip); if( Selection.getFocus() != sf ) { + var tc = this.__LZtextclip; + var v = tc.__lzview; + // Use cached values if available + if (v.blurring && tc.__cacheSelectionSize) { + return tc.__cacheSelectionSize; + } + return -1; } var siz = Selection.getEndIndex() - Selection.getBeginIndex(); Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzFocus.lzs =================================================================== --- openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzFocus.lzs 2007-07-19 20:44:38 UTC (rev 5716) +++ openlaszlo/branches/legals/WEB-INF/lps/lfc/services/LzFocus.lzs 2007-07-19 21:19:22 UTC (rev 5717) @@ -113,6 +113,10 @@ * event run before the next setFocus call is made. While it is not an error * for multiple responders to call setFocus as the result of the same onfocus * or onblur event, only one of the calls will be executed. + * + * The state of the view may be unknown during the blur/focus process. When + * a view loses focus, it's blurring variable is set to true during the + * process. * * @param LzView newsel: The view to focus or null to clear focus */ @@ -134,6 +138,12 @@ return; } + var prevsel = this.csel; + if (prevsel) { + // Give the view warning that it will be losing focus + prevsel.blurring = true; + } + this.__LZsfnextfocus = -1; this.__LZsfrunning = true; @@ -181,6 +191,11 @@ this.setFocus( this.__LZsfnextfocus ); return; } + + if (prevsel) { + // The focus is changed. + prevsel.blurring = false; + } } /** Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/services/platform/swf/LzModeManager.as =================================================================== --- openlaszlo/branches/legals/WEB-INF/lps/lfc/services/platform/swf/LzModeManager.as 2007-07-19 20:44:38 UTC (rev 5716) +++ openlaszlo/branches/legals/WEB-INF/lps/lfc/services/platform/swf/LzModeManager.as 2007-07-19 21:19:22 UTC (rev 5717) @@ -38,6 +38,15 @@ * @access private */ LzModeManager.rawMouseEvent = function ( eName ) { + // If applicable, update the current sprite's insertion position/size. + var focus = Selection.getFocus(); + if (focus) { + var textclip = eval(focus); // path -> object + if (textclip && textclip.__cacheSelection) { + textclip.__cacheSelection(); + } + } + //Debug.warn("rawmouseevent %w", eName); //not guaranteed Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloView.lzs =================================================================== --- openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloView.lzs 2007-07-19 20:44:38 UTC (rev 5716) +++ openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloView.lzs 2007-07-19 21:19:22 UTC (rev 5717) @@ -2441,6 +2441,14 @@ return true; } + +/** blurring is true if the view is in the process of losing focus. + * @type Boolean + */ +var blurring = false; + + + /** @access private */ static var __LZproxypolicies = []; _______________________________________________ Laszlo-checkins mailing list [email protected] http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins
