<mx:Script>
<![CDATA[

        /*
        Call this function at the start of this components life
        e.g. creationComplete="initApp()" in your window/component
        initial declaration
        */
        private function initApp():void
        {
                /*
                Add the listener to the input box you want to disable your
problem,
                you can map the same event handler function to multiple
password fields.

                */
                textInput.addEventListener(KeyboardEvent.KEY_DOWN,
textInputKeyDownEventHandler );
                //otherTextInput.addEventListener(KeyboardEvent.KEY_DOWN,
textInputKeyDownEventHandler );

//andAnotherTextInput.addEventListener(KeyboardEvent.KEY_DOWN,
textInputKeyDownEventHandler );
        }

        private function textInputKeyDownEventHandler(ev:KeyboardEvent):void
        {
                /*
                Check to see if the right combinations of buttons are
pressed.
                and ensure the text input is a password field.
                */
                if(ev.controlKey == true && ev.keyCode == Keyboard.C &&
ev.currentTarget.displayAsPassword == true)
                {
                        /*
                        This ensures the events normal behaviour of sending
the information to
                        the textInput is destroyed - we handle the rest
manually.

                        Checking if the event is cancelable ensures we are
allowed to
                        stop is normal job, however this 'if' statement is
redundant as
                        if we could not prevent the defaut action, it would
silently fail,
                        I only added this for the understanding of what it
tries to do.
                        */
                        if(ev.cancelable)
                        {
                                ev.preventDefault();
                        }

                         /*
                         Kill the event dead. This stops the event from
bubbling to the
                         operating system, and effectivly kills the copy
paste from
                         ever happening. Previous clipboard information is
left intact.
                         */
                         ev.stopPropagation();
                }
        }

On Sat, Jan 30, 2010 at 4:47 AM, Ravindra Kumar Challagandla <
[email protected]> wrote:

> I have created a component which restricts pasting into text area. I
> think same event works for the textInput as well. Please give it a
> try.
>
> Thanks,
> Ravindra.
>
> On Jan 29, 10:58 am, Jitendra Jain <[email protected]>
> wrote:
> > Well Ravindra, i don't think this will work because those are handled by
> > operating system first and then passed to Flex.
> >
> > On Fri, Jan 29, 2010 at 10:23 AM, Ravindra Kumar Challagandla <
> >
> > [email protected]> wrote:
> > > do event.preventDefault() in TextEvent.TEXT_INPUT event.. by doing so
> > > you can restrict pasting into text input.
> >
> > > On Jan 19, 5:06 pm, Raghavendra M <[email protected]> wrote:
> > > > Hi All,
> >
> > > > I have a requirement of disabling copying from and pasting into
> TextInput
> > > > component  in flex. I have tried by capturing the key Up and Down
> Events.
> > > > But it did not give full proof solution, i.e not always it was able
> to
> > > > detect the event.
> >
> > > > Any possible ideas or solution are appreciated.
> >
> > > > Thanks in Advance!!!
> >
> > > > Cheers,
> > > > Raghavendra.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Flex India Community" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<flex_india%[email protected]>
> <flex_india%2bunsubscr...@googlegrou­ps.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/flex_india?hl=en.
> >
> > --
> > Thanks and Regards,
> > JJain,
> >
> >   If you have knowledge, let others light their candles in it --Margaret
> > Fuller:
>
> --
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<flex_india%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to