|
|
|
[
Permlink
| « Hide
]
Jim Grandy - 21/May/07 03:31 PM
Even more ideally, the format button wouldn't steal focus at all...
need to remove #pragma workaround in our code to run in Legals -
LzModeManager.rawMouseEvent = function ( eName ) { //_root.Debug.warn("rawmouseevent %w", eName); //assume this happens before handleMouseEvent though order is //not guaranteed // Store the selection in the currently focused text field // (if any). Useful for restoring a text field's selection // after a click event. var focus = Selection.getFocus(); if (focus) { // focus is a path string - we have to eval() it to get // an actual movieclip var textclip = eval(focus); // apologies - dstowell #pragma "warnUndefinedReferences=false" // [NB dstowell] __LZrte is a field I created to // store a reference to a rich text editor view // in the textclip itself. This field is _not_ part // of the LFC. if (textclip.__LZrte) { var beginIndex = Selection.getBeginIndex(); var endIndex = Selection.getEndIndex(); if (-1 != beginIndex && -1 != endIndex) { textclip.__LZrte._ssel = beginIndex; textclip.__LZrte._esel = endIndex; } } } this.clickStream.push( this.clstDict[ eName ] ); //call the cleanup delegate this.callNext(); } He's just asking to remove the #pragma. Maybe Phil could dig in to why the #pragma is there and how to silence the warning without the #pragma?
Phil, you should not need a diamond set-up to investigate this, so why don't you take a stab at this right away. I'm assigning it to you for now. Let me know if you need help. Ok, I didn't read this carefully enough. I think the issue is an impedence mismatch between the runtime focus and our abstract concept of focus. By the time we send an LZX onblur, the runtime focus has already been lost. Dan's work-around seems reasonable to me and we ought to see about integrating it into the LFC. Basically, if there is an active selection in the runtime when focus changes, we should cache that so we can return that value, at least until we bubble the loss of focus up to the lzx node.
This app demonstrates the problem.
<canvas debug="true"> <simplelayout axis="y" spacing="20"/> <text>Select something in the input text and click the button</text> <button>Button <method event="onblur"> Debug.write("button: blur"); </method> <method event="onfocus"> Debug.write("button: focus"); </method> <method event="onclick"> Debug.write("button: click"); </method> </button> <richinputtext name="editor" width="300" height="200" bgcolor="0xeeeeee">Hello World <method event="onblur"> var start = this.getSelectionPosition(); var size = this.getSelectionSize(); Debug.write("richinputtext: blur", start, size); </method> <method event="onfocus"> Debug.write("richinputtext: focus"); </method> </richinputtext> </canvas> This is a better example app. It shows that richinputtext and inputtext views both work the same way.
<canvas debug="true"> <simplelayout axis="y" spacing="20"/> <text>Select something in the input text and click the button</text> <button>Button <method event="onblur"> Debug.write("button: blur"); </method> <method event="onfocus"> Debug.write("button: focus"); </method> <method event="onclick"> Debug.write("button: click"); </method> </button> <richinputtext name="editor" width="300" height="100" bgcolor="0xeeeeee">Hello World (richinputtext) <method event="onblur"> var start = this.getSelectionPosition(); var size = this.getSelectionSize(); Debug.write("richinputtext: blur", start, size); </method> <method event="onfocus"> Debug.write("richinputtext: focus"); </method> </richinputtext> <inputtext name="ieditor" width="300" height="100" bgcolor="0xeeeeee">Hello World (inputtext) <method event="onblur"> var start = this.getSelectionPosition(); var size = this.getSelectionSize(); Debug.write("inputtext: blur", start, size); </method> <method event="onfocus"> Debug.write("inputtext: focus"); </method> </inputtext> </canvas> Change 20070719-Philip-4 by Philip@Philip-DC 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: 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 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 (wafflecone branch local build r5986)
Fixed in wafflecone. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||