[flexcoders] Re: How to cancel Keyboard events?
I'm writing a masked edit control. I want to do various things at various times. I want to allow the deletion of certain characters. I want to allow editing of certain characters. All of which is dependent on the keyboard event/text input, mask, caret index, and selection begin/end index. The textInput event works perfectly. My issues center around trapping and ultimately rejecting (under certain cirucmstances) keyboard events for keys such as DELETE, BACKSPACE, LEFT, RIGHT, etc. I already have some code to workaround not being able to cancle the LEFT and RIGHT Keyboard events, but it doesn't look all that nice (you see the caret move and then move back). Thanks for the suggestions. However, I don't think what I'm trying to do is all that unusual. I've done it in numerous other languages and I don't think I should have to write excessive amounts of code to store and restore state when the same thing could be accomplished by having the appropriate control over the events. It seems like either I'm missing something or the language is. Thanks again. The suggestions are greatly appreciated. -Steven --- In flexcoders@yahoogroups.com, Chris Velevitch [EMAIL PROTECTED] wrote: On 5/19/06, Steven Toth [EMAIL PROTECTED] wrote: No dice. I do see the eventPhase equal to 1 (capture), but the stopPropagation() and stopImmediatePropagation() still do not prevent the DELETE from being processed. I'm beginning to think I'm just going about this the wrong way. There has to be a way to do this. As I understand it, capture only works for the container containing the text field, that is before the target gets it. And alternative would be to save the state of the text field and if the length is zero use the saved state to restore it. I'm assuming you want to prevent all the data from being deleted and but allow it to be edited. Chris -- Chris Velevitch Manager - Sydney Flash Platform Developers Group www.flashdev.org.au -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Re: [flexcoders] Re: How to cancel Keyboard events?
Here's a question for the keyboard cowboys that has stumped me for awhile Internet Explorer grabs the Control-S, Control-P, and Control-O keystrokes (and other commands) and they never even make it to the player. No Keydown event even occurs and this is with focus in the flash player (actually in a text input). It works 100% fine in Firefox (mapping Control-S to save) but it never works in IE. Ideas? On 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: I'm writing a masked edit control. I want to do various things at various times. I want to allow the deletion of certain characters. I want to allow editing of certain characters. All of which is dependent on the keyboard event/text input, mask, caret index, and selection begin/end index. The textInput event works perfectly. My issues center around trapping and ultimately rejecting (under certain cirucmstances) keyboard events for keys such as DELETE, BACKSPACE, LEFT, RIGHT, etc. I already have some code to workaround not being able to cancle the LEFT and RIGHT Keyboard events, but it doesn't look all that nice (you see the caret move and then move back). Thanks for the suggestions. However, I don't think what I'm trying to do is all that unusual. I've done it in numerous other languages and I don't think I should have to write excessive amounts of code to store and restore state when the same thing could be accomplished by having the appropriate control over the events. It seems like either I'm missing something or the language is. Thanks again. The suggestions are greatly appreciated. -Steven --- In flexcoders@yahoogroups.com, Chris Velevitch [EMAIL PROTECTED] wrote: On 5/19/06, Steven Toth [EMAIL PROTECTED] wrote: No dice. I do see the eventPhase equal to 1 (capture), but the stopPropagation() and stopImmediatePropagation() still do not prevent the DELETE from being processed. I'm beginning to think I'm just going about this the wrong way. There has to be a way to do this. As I understand it, capture only works for the container containing the text field, that is before the target gets it. And alternative would be to save the state of the text field and if the length is zero use the saved state to restore it. I'm assuming you want to prevent all the data from being deleted and but allow it to be edited. Chris -- Chris Velevitch Manager - Sydney Flash Platform Developers Group www.flashdev.org.au -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[flexcoders] Re: How to cancel Keyboard events?
That's fine for printable characters (i.e. text), but not for trapping and rejecting special keys like DELETE, BACKSPACE, LEFT, RIGHT, etc. Those keys don't initiate a textInput event. Try it. Thank for the suggestion though. -Steven --- In flexcoders@yahoogroups.com, Manish Jethani [EMAIL PROTECTED] wrote: On 5/19/06, Steven Toth [EMAIL PROTECTED] wrote: what should I be doing so I can reject certain keystrokes? Listen for the *textInput* event on the TextField at a higher priority and call preventDefault() on the event object. See the documentation for TextField and its textInput event. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
RE: [flexcoders] Re: How to cancel Keyboard events?
You're not missing anything. The fact that we provided a way for you to cancel text insertion but not text deletion is a design omission in the textInput event. I've filed a bug with the Player team, but given the schedule it may not get fixed. However, I think workarounds are possible. Here is some code that demonstrates that you can restore the old text and the old selection-- without flashing -- after both insertion and deletion. Run it, click in the text and then try typing characters or pressing Delete and Backspace. Nothing changes because I use the change event to restore the text and the selection back to the values they had at the textInput event. Try adapting this technique to your needs. ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml width=600 height=600 mx:Script ![CDATA[ import mx.core.mx_internal; private var savedText:String; private var savedCaretIndex:int; private function textInputHandler(event:TextEvent):void { savedText = ti.text; savedCaretIndex = ti.mx_internal::getTextField().caretIndex; } private function changeHandler(event:Event):void { ti.text = savedText; ti.setSelection(savedCaretIndex, savedCaretIndex); } ]] /mx:Script mx:TextInput id=ti text=Gordon textInput=textInputHandler(event) change=changeHandler(event)/ /mx:Application - Gordon -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steven Toth Sent: Thursday, May 18, 2006 8:49 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: How to cancel Keyboard events? I'm writing a masked edit control. I want to do various things at various times. I want to allow the deletion of certain characters. I want to allow editing of certain characters. All of which is dependent on the keyboard event/text input, mask, caret index, and selection begin/end index. The textInput event works perfectly. My issues center around trapping and ultimately rejecting (under certain cirucmstances) keyboard events for keys such as DELETE, BACKSPACE, LEFT, RIGHT, etc. I already have some code to workaround not being able to cancle the LEFT and RIGHT Keyboard events, but it doesn't look all that nice (you see the caret move and then move back). Thanks for the suggestions. However, I don't think what I'm trying to do is all that unusual. I've done it in numerous other languages and I don't think I should have to write excessive amounts of code to store and restore state when the same thing could be accomplished by having the appropriate control over the events. It seems like either I'm missing something or the language is. Thanks again. The suggestions are greatly appreciated. -Steven --- In flexcoders@yahoogroups.com, Chris Velevitch [EMAIL PROTECTED] wrote: On 5/19/06, Steven Toth [EMAIL PROTECTED] wrote: No dice. I do see the eventPhase equal to 1 (capture), but the stopPropagation() and stopImmediatePropagation() still do not prevent the DELETE from being processed. I'm beginning to think I'm just going about this the wrong way. There has to be a way to do this. As I understand it, capture only works for the container containing the text field, that is before the target gets it. And alternative would be to save the state of the text field and if the length is zero use the saved state to restore it. I'm assuming you want to prevent all the data from being deleted and but allow it to be edited. Chris -- Chris Velevitch Manager - Sydney Flash Platform Developers Group www.flashdev.org.au -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[flexcoders] Re: How to cancel Keyboard events?
Thanks for the feedback, but that does not do the trick. The event is not cancelable, so I cannot prevent the keystrokes. For example, I'm using a TextInput control. I can handle the textInput event and cancel it (not allow the new text to be input) using the prevenDefault() method. However, the keyDown and keyUp events are not cancelable. Hence I cannot prevent my user from deleting text from the control via the DELETE key. The stopPropagation() and stopImmediatePropagation() method do not work since the event has already been processed and the text deleted by the time it gets to the keyDown and keyUp events. It seems that there must be someway to be able to reject or respond in a custom way to keyDown/keyUp events??? --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, Well, looking at how Adobe did somethings, I would say you could either write a filter loop that executes in the keyDown handler or just hard code the keys you want to reject. I don't know if this helps you but, there is; keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() See the docs for the lengthy definition of those methods. Being email and all it sounds like you just need to do alittle ditch digging ;-) IE put in an if statement with logical || . Peace, Mike On 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: I'm trying to write a custom control and I need to be able to reject certain keystrokes. I'm able to add listeners for the KeyBoardEvent, but they are not cancelable. I don't see anywhere in the object heirarchy that they are. I'm probably missing something since I'm approaching this from a perspective of developing similar controls in .NET and Java. Is handling the KeyboardEvent the correct way to do this? If so, how do I handle the event so that I can cancel it? If not, what should I be doing so I can reject certain keystrokes? Thanks. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders% 40yahoogroups.com SPONSORED LINKS Web site design developmenthttp://groups.yahoo.com/gads? t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2= Computer+software+developmentw3=Software+design+and+developmentw4=M acromedia+flexw5=Software+development+best+practicec=5s=166.sig=L -4QTvxB_quFDtMyhrQaHQ Computer software developmenthttp://groups.yahoo.com/gads? t=msk=Computer+software+developmentw1=Web+site+design+developmentw 2=Computer+software+developmentw3=Software+design+and+developmentw4 =Macromedia+flexw5=Software+development+best+practicec=5s=166.sig =lvQjSRfQDfWudJSe1lLjHw Software design and developmenthttp://groups.yahoo.com/gads? t=msk=Software+design+and+developmentw1=Web+site+design+development w2=Computer+software+developmentw3=Software+design+and+development w4=Macromedia+flexw5=Software+development+best+practicec=5s=166.s ig=1pMBCdo3DsJbuU9AEmO1oQ Macromedia flexhttp://groups.yahoo.com/gads? t=msk=Macromedia+flexw1=Web+site+design+developmentw2=Computer+sof tware+developmentw3=Software+design+and+developmentw4=Macromedia+fl exw5=Software+development+best+practicec=5s=166.sig=OO6nPIrz7_EpZ I36cYzBjw Software development best practicehttp://groups.yahoo.com/gads? t=msk=Software+development+best+practicew1=Web+site+design+developm entw2=Computer+software+developmentw3=Software+design+and+developme ntw4=Macromedia+flexw5=Software+development+best+practicec=5s=166 .sig=f89quyyulIDsnABLD6IXIw -- YAHOO! GROUPS LINKS - Visit your group flexcodershttp://groups.yahoo.com/group/flexcoders on the web. - To unsubscribe from this group, send an email to: [EMAIL PROTECTED]flexcoders- [EMAIL PROTECTED] - Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service http://docs.yahoo.com/info/terms/. -- -- What goes up, does come down. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Re: [flexcoders] Re: How to cancel Keyboard events?
Ah, I got ya. Yeah, I know I read somwhere in the docs about this issue. I can't remeber if it pertains to your particular problem. EDIT - I looked and now REALLY understand you. As far as I know, IE delete, there is no way as of yet. ... But don't take my word for it ;-) I don't think there is a way to do what you want, AS seems to be one layer to high for that interaction other than like you said, make the behavior cancelable.. Never know for the future though, they might be listening. :) Peace, MikeOn 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: Thanks for the feedback, but that does not do the trick. The event is not cancelable, so I cannot prevent the keystrokes. For example, I'm using a TextInput control. I can handle the textInput event and cancel it (not allow the new text to be input) using the prevenDefault() method. However, the keyDown and keyUp events are not cancelable. Hence I cannot prevent my user from deleting text from the control via the DELETE key. The stopPropagation() and stopImmediatePropagation() method do not work since the event has already been processed and the text deleted by the time it gets to the keyDown and keyUp events. It seems that there must be someway to be able to reject or respond in a custom way to keyDown/keyUp events??? --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, Well, looking at how Adobe did somethings, I would say you could either write a filter loop that executes in the keyDown handler or just hard code the keys you want to reject. I don't know if this helps you but, there is; keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() See the docs for the lengthy definition of those methods. Being email and all it sounds like you just need to do alittle ditch digging ;-) IE put in an if statement with logical || . Peace, Mike On 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: I'm trying to write a custom control and I need to be able to reject certain keystrokes. I'm able to add listeners for the KeyBoardEvent, but they are not cancelable. I don't see anywhere in the object heirarchy that they are. I'm probably missing something since I'm approaching this from a perspective of developing similar controls in .NET and Java. Is handling the KeyboardEvent the correct way to do this? If so, how do I handle the event so that I can cancel it? If not, what should I be doing so I can reject certain keystrokes? Thanks. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders% 40yahoogroups.com SPONSORED LINKS Web site design developmenthttp://groups.yahoo.com/gads? t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2= Computer+software+developmentw3=Software+design+and+developmentw4=M acromedia+flexw5=Software+development+best+practicec=5s=166.sig=L -4QTvxB_quFDtMyhrQaHQ Computer software developmenthttp://groups.yahoo.com/gads? t=msk=Computer+software+developmentw1=Web+site+design+developmentw 2=Computer+software+developmentw3=Software+design+and+developmentw4 =Macromedia+flexw5=Software+development+best+practicec=5s=166.sig =lvQjSRfQDfWudJSe1lLjHw Software design and developmenthttp://groups.yahoo.com/gads? t=msk=Software+design+and+developmentw1=Web+site+design+development w2=Computer+software+developmentw3=Software+design+and+development w4=Macromedia+flexw5=Software+development+best+practicec=5s=166.s ig=1pMBCdo3DsJbuU9AEmO1oQ Macromedia flexhttp://groups.yahoo.com/gads? t=msk=Macromedia+flexw1=Web+site+design+developmentw2=Computer+sof tware+developmentw3=Software+design+and+developmentw4=Macromedia+fl exw5=Software+development+best+practicec=5s=166.sig=OO6nPIrz7_EpZ I36cYzBjw Software development best practicehttp://groups.yahoo.com/gads? t=msk=Software+development+best+practicew1=Web+site+design+developm entw2=Computer+software+developmentw3=Software+design+and+developme ntw4=Macromedia+flexw5=Software+development+best+practicec=5s=166 .sig=f89quyyulIDsnABLD6IXIw -- YAHOO! GROUPS LINKS - Visit your group flexcodershttp://groups.yahoo.com/group/flexcoders on the web. - To unsubscribe from this group, send an email to: [EMAIL PROTECTED]flexcoders- [EMAIL PROTECTED] - Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service http://docs.yahoo.com/info/terms/. -- -- What goes up, does come down. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development
Re: [flexcoders] Re: How to cancel Keyboard events?
write this off top my head, but there are two phases for event, one is capturing phase, the other bubbling phase. I guess what you need to do is like this: Application.application.addEventListener(keyDown, onKeyDown, true); setting third param to true will switch to capture phase, then you get the chance to do : keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() as Michael suggested, this will prevent keyDown event from being picked up by underlying components. see if that works. On 5/19/06, Michael Schmalle [EMAIL PROTECTED] wrote: Ah, I got ya. Yeah, I know I read somwhere in the docs about this issue. I can't remeber if it pertains to your particular problem. EDIT - I looked and now REALLY understand you. As far as I know, IE delete, there is no way as of yet. ... But don't take my word for it ;-) I don't think there is a way to do what you want, AS seems to be one layer to high for that interaction other than like you said, make the behavior cancelable.. Never know for the future though, they might be listening. :) Peace, MikeOn 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: Thanks for the feedback, but that does not do the trick. The event is not cancelable, so I cannot prevent the keystrokes. For example, I'm using a TextInput control. I can handle the textInput event and cancel it (not allow the new text to be input) using the prevenDefault() method. However, the keyDown and keyUp events are not cancelable. Hence I cannot prevent my user from deleting text from the control via the DELETE key. The stopPropagation() and stopImmediatePropagation() method do not work since the event has already been processed and the text deleted by the time it gets to the keyDown and keyUp events. It seems that there must be someway to be able to reject or respond in a custom way to keyDown/keyUp events??? --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, Well, looking at how Adobe did somethings, I would say you could either write a filter loop that executes in the keyDown handler or just hard code the keys you want to reject. I don't know if this helps you but, there is; keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() See the docs for the lengthy definition of those methods. Being email and all it sounds like you just need to do alittle ditch digging ;-) IE put in an if statement with logical || . Peace, Mike On 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: I'm trying to write a custom control and I need to be able to reject certain keystrokes. I'm able to add listeners for the KeyBoardEvent, but they are not cancelable. I don't see anywhere in the object heirarchy that they are. I'm probably missing something since I'm approaching this from a perspective of developing similar controls in .NET and Java. Is handling the KeyboardEvent the correct way to do this? If so, how do I handle the event so that I can cancel it? If not, what should I be doing so I can reject certain keystrokes? Thanks. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders% 40yahoogroups.com SPONSORED LINKS Web site design developmenthttp://groups.yahoo.com/gads? t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2= Computer+software+developmentw3=Software+design+and+developmentw4=M acromedia+flexw5=Software+development+best+practicec=5s=166.sig=L -4QTvxB_quFDtMyhrQaHQ Computer software developmenthttp://groups.yahoo.com/gads? t=msk=Computer+software+developmentw1=Web+site+design+developmentw 2=Computer+software+developmentw3=Software+design+and+developmentw4 =Macromedia+flexw5=Software+development+best+practicec=5s=166.sig =lvQjSRfQDfWudJSe1lLjHw Software design and developmenthttp://groups.yahoo.com/gads? t=msk=Software+design+and+developmentw1=Web+site+design+development w2=Computer+software+developmentw3=Software+design+and+development w4=Macromedia+flexw5=Software+development+best+practicec=5s=166.s ig=1pMBCdo3DsJbuU9AEmO1oQ Macromedia flexhttp://groups.yahoo.com/gads? t=msk=Macromedia+flexw1=Web+site+design+developmentw2=Computer+sof tware+developmentw3=Software+design+and+developmentw4=Macromedia+fl exw5=Software+development+best+practicec=5s=166.sig=OO6nPIrz7_EpZ I36cYzBjw Software development best practicehttp://groups.yahoo.com/gads? t=msk=Software+development+best+practicew1=Web+site+design+developm entw2=Computer+software+developmentw3=Software+design+and+developme ntw4=Macromedia+flexw5=Software+development+best+practicec=5s=166 .sig=f89quyyulIDsnABLD6IXIw -- YAHOO! GROUPS LINKS - Visit your group flexcodershttp://groups.yahoo.com/group/flexcoders on the web. - To unsubscribe from this group, send an email to: [EMAIL PROTECTED]flexcoders- [EMAIL PROTECTED] - Your use of Yahoo! Groups
Re: [flexcoders] Re: How to cancel Keyboard events?
Jeremy, If that works... props to you man! ;-) Peace, MikeOn 5/18/06, jeremy lu [EMAIL PROTECTED] wrote: write this off top my head, but there are two phases for event, one is capturing phase, the other bubbling phase. I guess what you need to do is like this: Application.application.addEventListener(keyDown, onKeyDown, true); setting third param to true will switch to capture phase, then you get the chance to do : keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() as Michael suggested, this will prevent keyDown event from being picked up by underlying components. see if that works. On 5/19/06, Michael Schmalle [EMAIL PROTECTED] wrote: Ah, I got ya. Yeah, I know I read somwhere in the docs about this issue. I can't remeber if it pertains to your particular problem. EDIT - I looked and now REALLY understand you. As far as I know, IE delete, there is no way as of yet. ... But don't take my word for it ;-) I don't think there is a way to do what you want, AS seems to be one layer to high for that interaction other than like you said, make the behavior cancelable.. Never know for the future though, they might be listening. :) Peace, MikeOn 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: Thanks for the feedback, but that does not do the trick. The event is not cancelable, so I cannot prevent the keystrokes. For example, I'm using a TextInput control. I can handle the textInput event and cancel it (not allow the new text to be input) using the prevenDefault() method. However, the keyDown and keyUp events are not cancelable. Hence I cannot prevent my user from deleting text from the control via the DELETE key. The stopPropagation() and stopImmediatePropagation() method do not work since the event has already been processed and the text deleted by the time it gets to the keyDown and keyUp events. It seems that there must be someway to be able to reject or respond in a custom way to keyDown/keyUp events??? --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, Well, looking at how Adobe did somethings, I would say you could either write a filter loop that executes in the keyDown handler or just hard code the keys you want to reject. I don't know if this helps you but, there is; keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() See the docs for the lengthy definition of those methods. Being email and all it sounds like you just need to do alittle ditch digging ;-) IE put in an if statement with logical || . Peace, Mike On 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: I'm trying to write a custom control and I need to be able to reject certain keystrokes. I'm able to add listeners for the KeyBoardEvent, but they are not cancelable. I don't see anywhere in the object heirarchy that they are. I'm probably missing something since I'm approaching this from a perspective of developing similar controls in .NET and Java. Is handling the KeyboardEvent the correct way to do this? If so, how do I handle the event so that I can cancel it? If not, what should I be doing so I can reject certain keystrokes? Thanks. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders% 40yahoogroups.com SPONSORED LINKS Web site design developmenthttp://groups.yahoo.com/gads? t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2= Computer+software+developmentw3=Software+design+and+developmentw4=M acromedia+flexw5=Software+development+best+practicec=5s=166.sig=L -4QTvxB_quFDtMyhrQaHQ Computer software developmenthttp://groups.yahoo.com/gads? t=msk=Computer+software+developmentw1=Web+site+design+developmentw 2=Computer+software+developmentw3=Software+design+and+developmentw4 =Macromedia+flexw5=Software+development+best+practicec=5s=166.sig =lvQjSRfQDfWudJSe1lLjHw Software design and developmenthttp://groups.yahoo.com/gads? t=msk=Software+design+and+developmentw1=Web+site+design+development w2=Computer+software+developmentw3=Software+design+and+development w4=Macromedia+flexw5=Software+development+best+practicec=5s=166.s ig=1pMBCdo3DsJbuU9AEmO1oQ Macromedia flexhttp://groups.yahoo.com/gads? t=msk=Macromedia+flexw1=Web+site+design+developmentw2=Computer+sof tware+developmentw3=Software+design+and+developmentw4=Macromedia+fl exw5=Software+development+best+practicec=5s=166.sig=OO6nPIrz7_EpZ I36cYzBjw Software development best practicehttp://groups.yahoo.com/gads? t=msk=Software+development+best+practicew1=Web+site+design+developm entw2=Computer+software+developmentw3=Software+design+and+developme ntw4=Macromedia+flexw5=Software+development+best+practicec=5s=166 .sig=f89quyyulIDsnABLD6IXIw -- YAHOO! GROUPS LINKS - Visit your group flexcodershttp://groups.yahoo.com/group/flexcoders on the web. - To unsubscribe
[flexcoders] Re: How to cancel Keyboard events?
No dice. I do see the eventPhase equal to 1 (capture), but the stopPropagation() and stopImmediatePropagation() still do not prevent the DELETE from being processed. I'm beginning to think I'm just going about this the wrong way. There has to be a way to do this. I'd love to see what's going in under the covers. Is the source code for the flash namespaces available. I looked through the mx namespaces, but the bulk of what I'm interested in is in the flash namespaces. --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Jeremy, If that works... props to you man! ;-) Peace, Mike On 5/18/06, jeremy lu [EMAIL PROTECTED] wrote: write this off top my head, but there are two phases for event, one is capturing phase, the other bubbling phase. I guess what you need to do is like this: Application.application.addEventListener(keyDown, onKeyDown, true); setting third param to true will switch to capture phase, then you get the chance to do : keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() as Michael suggested, this will prevent keyDown event from being picked up by underlying components. see if that works. On 5/19/06, Michael Schmalle [EMAIL PROTECTED] wrote: Ah, I got ya. Yeah, I know I read somwhere in the docs about this issue. I can't remeber if it pertains to your particular problem. EDIT - I looked and now REALLY understand you. As far as I know, IE delete, there is no way as of yet. ... But don't take my word for it ;-) I don't think there is a way to do what you want, AS seems to be one layer to high for that interaction other than like you said, make the behavior cancelable.. Never know for the future though, they might be listening. :) Peace, Mike On 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: Thanks for the feedback, but that does not do the trick. The event is not cancelable, so I cannot prevent the keystrokes. For example, I'm using a TextInput control. I can handle the textInput event and cancel it (not allow the new text to be input) using the prevenDefault() method. However, the keyDown and keyUp events are not cancelable. Hence I cannot prevent my user from deleting text from the control via the DELETE key. The stopPropagation() and stopImmediatePropagation() method do not work since the event has already been processed and the text deleted by the time it gets to the keyDown and keyUp events. It seems that there must be someway to be able to reject or respond in a custom way to keyDown/keyUp events??? --- In flexcoders@yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Hi, Well, looking at how Adobe did somethings, I would say you could either write a filter loop that executes in the keyDown handler or just hard code the keys you want to reject. I don't know if this helps you but, there is; keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() See the docs for the lengthy definition of those methods. Being email and all it sounds like you just need to do alittle ditch digging ;-) IE put in an if statement with logical || . Peace, Mike On 5/18/06, Steven Toth steventoth@ wrote: I'm trying to write a custom control and I need to be able to reject certain keystrokes. I'm able to add listeners for the KeyBoardEvent, but they are not cancelable. I don't see anywhere in the object heirarchy that they are. I'm probably missing something since I'm approaching this from a perspective of developing similar controls in .NET and Java. Is handling the KeyboardEvent the correct way to do this? If so, how do I handle the event so that I can cancel it? If not, what should I be doing so I can reject certain keystrokes? Thanks. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders% http://www.mail-archive.com/flexcoders%25 40yahoogroups.com SPONSORED LINKS Web site design developmenthttp://groups.yahoo.com/gads? t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2= Computer+software+developmentw3=Software+design+and+developmentw4=M acromedia+flexw5=Software+development+best+practicec=5s=166.sig=L -4QTvxB_quFDtMyhrQaHQ Computer software developmenthttp://groups.yahoo.com/gads? t=msk=Computer+software+developmentw1=Web+site+design+developmentw 2=Computer+software+developmentw3=Software+design+and+developmentw4 =Macromedia+flexw5=Software+development+best+practicec=5s=166.sig =lvQjSRfQDfWudJSe1lLjHw
Re: [flexcoders] Re: How to cancel Keyboard events?
well, if DELETE is the only key you want to rule out, why not just do a if...else to detect it ? On 5/19/06, Steven Toth [EMAIL PROTECTED] wrote: No dice.I do see the eventPhase equal to 1 (capture), but thestopPropagation() and stopImmediatePropagation() still do notprevent the DELETE from being processed.I'm beginning to think I'mjust going about this the wrong way.There has to be a way to do this.I'd love to see what's going in under the covers.Is the sourcecode for the flash namespaces available.I looked through the mxnamespaces, but the bulk of what I'm interested in is in the flash namespaces. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
RE: [flexcoders] Re: How to cancel Keyboard events?
I think not being able to cancel DELETE is an oversight in the design; I'll file a bug about this. You'll probably have to allow the deletion to happen and then restore the previous text afterwards. - Gordon -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steven Toth Sent: Thursday, May 18, 2006 5:40 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: How to cancel Keyboard events? No dice. I do see the eventPhase equal to 1 (capture), but the stopPropagation() and stopImmediatePropagation() still do not prevent the DELETE from being processed. I'm beginning to think I'm just going about this the wrong way. There has to be a way to do this. I'd love to see what's going in under the covers. Is the source code for the flash namespaces available. I looked through the mx namespaces, but the bulk of what I'm interested in is in the flash namespaces. --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Jeremy, If that works... props to you man! ;-) Peace, Mike On 5/18/06, jeremy lu [EMAIL PROTECTED] wrote: write this off top my head, but there are two phases for event, one is capturing phase, the other bubbling phase. I guess what you need to do is like this: Application.application.addEventListener(keyDown, onKeyDown, true); setting third param to true will switch to capture phase, then you get the chance to do : keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() as Michael suggested, this will prevent keyDown event from being picked up by underlying components. see if that works. On 5/19/06, Michael Schmalle [EMAIL PROTECTED] wrote: Ah, I got ya. Yeah, I know I read somwhere in the docs about this issue. I can't remeber if it pertains to your particular problem. EDIT - I looked and now REALLY understand you. As far as I know, IE delete, there is no way as of yet. ... But don't take my word for it ;-) I don't think there is a way to do what you want, AS seems to be one layer to high for that interaction other than like you said, make the behavior cancelable.. Never know for the future though, they might be listening. :) Peace, Mike On 5/18/06, Steven Toth [EMAIL PROTECTED] wrote: Thanks for the feedback, but that does not do the trick. The event is not cancelable, so I cannot prevent the keystrokes. For example, I'm using a TextInput control. I can handle the textInput event and cancel it (not allow the new text to be input) using the prevenDefault() method. However, the keyDown and keyUp events are not cancelable. Hence I cannot prevent my user from deleting text from the control via the DELETE key. The stopPropagation() and stopImmediatePropagation() method do not work since the event has already been processed and the text deleted by the time it gets to the keyDown and keyUp events. It seems that there must be someway to be able to reject or respond in a custom way to keyDown/keyUp events??? --- In flexcoders@yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Hi, Well, looking at how Adobe did somethings, I would say you could either write a filter loop that executes in the keyDown handler or just hard code the keys you want to reject. I don't know if this helps you but, there is; keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() See the docs for the lengthy definition of those methods. Being email and all it sounds like you just need to do alittle ditch digging ;-) IE put in an if statement with logical || . Peace, Mike On 5/18/06, Steven Toth steventoth@ wrote: I'm trying to write a custom control and I need to be able to reject certain keystrokes. I'm able to add listeners for the KeyBoardEvent, but they are not cancelable. I don't see anywhere in the object heirarchy that they are. I'm probably missing something since I'm approaching this from a perspective of developing similar controls in .NET and Java. Is handling the KeyboardEvent the correct way to do this? If so, how do I handle the event so that I can cancel it? If not, what should I be doing so I can reject certain keystrokes? Thanks. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders% http://www.mail-archive.com/flexcoders%25 40yahoogroups.com SPONSORED LINKS Web site design developmenthttp://groups.yahoo.com/gads? t=msk=Web+site+design+developmentw1=Web+site+design+developmentw2= Computer+software+developmentw3
[flexcoders] Re: How to cancel Keyboard events?
Thanks. Two things though... It's not just DELETE, it's any keyboard event (KEY_UP, KEY_DOWN). Another thing I've noticed is that the caretIndex of the TextField is not accurate on the focusIn event. It shows as the last position in the TextField instead of the position the user clicked. Thanks again for your help. -Steven --- In flexcoders@yahoogroups.com, Gordon Smith [EMAIL PROTECTED] wrote: I think not being able to cancel DELETE is an oversight in the design; I'll file a bug about this. You'll probably have to allow the deletion to happen and then restore the previous text afterwards. - Gordon -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steven Toth Sent: Thursday, May 18, 2006 5:40 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: How to cancel Keyboard events? No dice. I do see the eventPhase equal to 1 (capture), but the stopPropagation() and stopImmediatePropagation() still do not prevent the DELETE from being processed. I'm beginning to think I'm just going about this the wrong way. There has to be a way to do this. I'd love to see what's going in under the covers. Is the source code for the flash namespaces available. I looked through the mx namespaces, but the bulk of what I'm interested in is in the flash namespaces. --- In flexcoders@yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Jeremy, If that works... props to you man! ;-) Peace, Mike On 5/18/06, jeremy lu wade.lu@ wrote: write this off top my head, but there are two phases for event, one is capturing phase, the other bubbling phase. I guess what you need to do is like this: Application.application.addEventListener(keyDown, onKeyDown, true); setting third param to true will switch to capture phase, then you get the chance to do : keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() as Michael suggested, this will prevent keyDown event from being picked up by underlying components. see if that works. On 5/19/06, Michael Schmalle teoti.graphix@ wrote: Ah, I got ya. Yeah, I know I read somwhere in the docs about this issue. I can't remeber if it pertains to your particular problem. EDIT - I looked and now REALLY understand you. As far as I know, IE delete, there is no way as of yet. ... But don't take my word for it ;-) I don't think there is a way to do what you want, AS seems to be one layer to high for that interaction other than like you said, make the behavior cancelable.. Never know for the future though, they might be listening. :) Peace, Mike On 5/18/06, Steven Toth steventoth@ wrote: Thanks for the feedback, but that does not do the trick. The event is not cancelable, so I cannot prevent the keystrokes. For example, I'm using a TextInput control. I can handle the textInput event and cancel it (not allow the new text to be input) using the prevenDefault() method. However, the keyDown and keyUp events are not cancelable. Hence I cannot prevent my user from deleting text from the control via the DELETE key. The stopPropagation () and stopImmediatePropagation() method do not work since the event has already been processed and the text deleted by the time it gets to the keyDown and keyUp events. It seems that there must be someway to be able to reject or respond in a custom way to keyDown/keyUp events??? --- In flexcoders@yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Hi, Well, looking at how Adobe did somethings, I would say you could either write a filter loop that executes in the keyDown handler or just hard code the keys you want to reject. I don't know if this helps you but, there is; keyEvent.stopPropagation() keyEvent.stopImmediatePropagation() See the docs for the lengthy definition of those methods. Being email and all it sounds like you just need to do alittle ditch digging ;-) IE put in an if statement with logical || . Peace, Mike On 5/18/06, Steven Toth steventoth@ wrote: I'm trying to write a custom control and I need to be able to reject certain keystrokes. I'm able to add listeners for the KeyBoardEvent, but they are not cancelable. I don't see anywhere in the object heirarchy that they are. I'm probably missing something since I'm approaching this from a perspective of developing similar controls in .NET and Java. Is handling the KeyboardEvent the correct way to do this? If so, how do I handle the event so that I can cancel it? If not, what