That's probably sufficient, although it sounds like a bit of a kludge to me.

It makes me believe all the stronger that the issue is we want the UI to _not_ 
display the selection when we don't have focus, but we still want to be able to 
ask what the selection is/was.

I think André's analysis is important.  You can either gain/lose focus and/or 
apply/remove selection by UI gestures, _or_ programmatically.  On top of that, 
the desired behavior is to _not_ display the selection when you don't have 
focus, but also to be able to query what the selection is/was, whether you have 
focus or not.

So, I think a better way to solve this problem, rather than just delaying the 
deselect one tick, is for the sprite to cache the selection state and use the 
cache to report back the state, not rely on the platform UI element to maintain 
it.

Gee, this seems to be why it works for <text>:  see the swf8 implementation of 
LzTextSprite/__cacheSelection.  We just need to implement that uniformly.

On 2010-12-05, at 10:53, Henry Minsky wrote:

> Andre did some detective work and noticed that in swf8, we defer the "blur"
> call using an onidle callback , and there is a
> cryptic comment about that which implies we're leaving enough time for
> whoever else was clicked on to grab the selection before we clear it.
> 
> 
> /**
>  * @access private
>  */
> TextField.prototype.__lostFocus = function () {
>    if (this['__handlelostFocusdel'] == null) {
>        this.__handlelostFocusdel = new LzDelegate(this,
> "__handlelostFocus");
>    }
>    lz.Idle.callOnIdle(this.__handlelostFocusdel);
> }
> 
> /**
>  * must be called after an idle event to prevent the selection from being
>  * cleared prematurely, e.g. before a button click.  If the selection is
>  * cleared, the button doesn't send mouse events.
>  * @access private
>  */
> TextField.prototype.__handlelostFocus = function (ignore) {
>    if (this.__lzview) this.__lzview.inputtextevent('onblur');
> }
> 
> So for Fred's purposes, in swf10 it might be sufficient to also place the
> call to deselect() in an onidle callback,
> and maybe his application would have time to copy the selection before it
> was cleared?
> 
> 
> 
> 
> 
> On Sun, Dec 5, 2010 at 8:20 AM, André Bargull <[email protected]> wrote:
> 
>> The various deselect() methods do different things:
>> swf8:
>> - clears the native flash focus
>> swf9+:
>> - sets the selection size to zero
>> dhtml:
>> - hides the click-divs, restores cancelKeys, etc.
>> 
>> Therefore simply removing the call to deselect() sounds a bit wrong.
>> 
>> ---
>> 
>> In general, focus handling for the swf runtimes is implemented as follows:
>> (1) Explicit focus changes by Lz.Focus:
>> a) "onfocus" ::
>> lz.InputText#_gotFocusEvent() -> LzInputTextSprite#gotFocus() ->
>> LzInputTextSprite#select() [followed by instructions in 2a]
>> b) "onblur" ::
>> lz.InputText#_gotBlurEvent() -> LzInputTextSprite#gotBlur() ->
>> LzInputTextSprite#deselect() [followed by instructions in 2b]
>> 
>> (2) Native focus changes:
>> a) "onSetFocus" / "FOCUS_IN" ::
>> LzInputTextSprite#__gotFocus() -> lz.InputText#inputtextevent('onfocus') ->
>> Lz.Focus.setFocus() [followed by instructions in 1a]
>> b) "onKillFocus" / "FOCUS_OUT" ::
>> LzInputTextSprite#__lostFocus() -> lz.InputText#inputtextevent('onblur') ->
>> Lz.Focus.clearFocus() [followed by instructions in 1b]
>> 
>> swf8 defers the call to inputtextevent('onblur'), see __handlelostFocus().
>> Maybe the intent was to make it possible to query the selection before the
>> native focus is removed, here's the comment from that function:
>> 
>>> /**
>>> * must be called after an idle event to prevent the selection from being
>>> * cleared prematurely, e.g. before a button click.  If the selection is
>>> * cleared, the button doesn't send mouse events.
>>> * @access private
>>> */
>>> 
>> The first sentence indicates this is about querying the selection. But I'm
>> not sure about the second sentence, maybe someone else can explain what it
>> means...
>> 
>> 
>> 
>> 
>> 
>> On 12/5/2010 6:43 AM, Henry Minsky wrote:
>> 
>>> 
>>> Change hqm-20101205-R9I by [email protected] on 2010-12-05 00:39:47 EST
>>>    in /Users/hqm/openlaszlo/trunk2
>>>    for http://svn.openlaszlo.org/openlaszlo/trunk
>>> 
>>> Summary:  LzInputTextSprite.gotBlur should not clear selection
>>> 
>>> New Features:
>>> 
>>> Bugs Fixed: LPP-9562
>>> 
>>> Technical Reviewer: max
>>> QA Reviewer: ffeng
>>> Doc Reviewer: (pending)
>>> 
>>> Documentation:
>>> 
>>> Release Notes:
>>> 
>>> Overview:
>>> 
>>> 
>>> Details:
>>> 
>>> This change makes it so that LzInputTextSprite.gotBlur no longer clears
>>> the selection
>>> 
>>> 
>>> Tests:
>>> 
>>> test case from bug report
>>> 
>>> Files:
>>> 
>>> M       WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as
>>> M       WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
>>> M       WEB-INF/lps/lfc/kernel/swf9/LzInputTextSprite.as
>>> 
>>> Changeset:
>>> http://svn.openlaszlo.org/openlaszlo/patches/hqm-20101205-R9I.tar
>>> 
>>> 
>>> 
> 
> 
> -- 
> Henry Minsky
> Software Architect
> [email protected]


Reply via email to