You have to rework your logic to the way flash handles selections,
Note, there can be a lag between new selections.
Also some things you just wont be able to do :(
 

> 2. A button appears near the selected text 3. The user taps the button 4.
The text field loses focus, launching Selection.onSetFocus, which checks if
the current selection, >
> now "null", is an editable textfield. Naturally, null is not, so the
button becomes hidden.

Focus will go something like
TextField, null, Button, If your listening for onSetFocus
Here's what I used 

        public function onTextFocusOut( event : Object ) : Void
        {
                clearInterval( this.searchTextForRuleInterval );
                getNextSelectionCounter = 0;
                getNextSelectionInterval = setInterval( this,
"getNextSelection", 100 );
                Key.removeListener( this );
                Mouse.removeListener( this );
        }

        private function getNextSelection() : Void
        {
                var sFocus : String = String( Selection.getFocus() );
                var aIndex : Number = sFocus.indexOf( "addRule_btn" );
                var bIndex : Number = sFocus.indexOf( "displayText" );
                var cIndex : Number = sFocus.indexOf( "Commit_btn" );

                if ( aIndex !== -1 || cIndex !== -1 )
                {
                        clearInterval( this.getNextSelectionInterval );
                        return;
                }

                else if ( sFocus == undefined || sFocus == "null" || sFocus
== null )
                {
                        this.getNextSelectionCounter ++;
                        if ( this.getNextSelectionCounter >= 6)
                        {
                                clearInterval( this.getNextSelectionInterval
);
                                return;
                        }
                }
                else if ( bIndex == -1 && sFocus !== undefined )
                {
                        if ( sFocus == undefined || sFocus == "null" ||
sFocus == null )
                        {
                                return;
                        }
                        else
                        {
        
ds.currentManager.getActions().updateState(ActionStates.commonWizardNav);
                                clearInterval( this.getNextSelectionInterval
);
                                return;
                        }
                }
        }



Although the code is ugly atleast it helps you determine what really
actually has focus!


Hope I helped....


Regards,
 
Bjorn Schultheiss
Senior Flash Developer
QDC Technologies

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andreas
Rønning
Sent: Monday, 2 October 2006 9:13 PM
To: Flashcoders mailing list
Subject: [Flashcoders] Selection class makes me want to kick someone in
theface

...which is, i gather, somewhat of a general consensus.

I'm working on a tablet pc application that requires the user to be able to
select text and transfer this text to other parts of the application.
The ideal way is as such:

1. The user makes a selection from *any selectable text field* 2. A button
appears near the selected text 3. The user taps the button 4. The selected
text is copied to a buffer 5. The selection is cleared 6. An event is
broadcast

Now my problem is, this is what happens:

1. The user makes a selection
2. A button appears near the selected text 3. The user taps the button 4.
The text field loses focus, launching Selection.onSetFocus, which checks if
the current selection, now "null", is an editable textfield. Naturally, null
is not, so the button becomes hidden.
5. The user releases the now invisible button 6. Selection.onSetFocus
gathers that the new selection is "null", and uh, returns focus to the text
field, which retains its selection.
7. Now that the textfield, which is "valid" in terms of this purpose, the
button is shown again.

Hmm.. Infinite cycle. Not cool.

The big issue here is that Selection.onSetFocus is called prior to
MovieClip.onPress. This basically means there's no way i can make changes to
the current selection before onSetFocus is called. With this in mind: How
the bloody hell is it possible to make changes to a selection with a button?
The more i kick this horse around, the more contrived the AS looks, and it's
becoming seriously demoralizing.

Any input is appreciated.

- A
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to