A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How to cancel Bubble on Keyboard Event?

Hybrid View

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Posts
    150

    How to cancel Bubble on Keyboard Event?

    I'm trying to trap the "TAB" key so that it only changes the focus of input text boxes in my movie. I have used the following code. The code works however, the event bubbles up and objects in the movie change focus as the "TAB" key is pressed.

    I have tried returning both "true" and "false" in my listener and it makes no difference.

    Any help would be appreciated.


    Code:

    Code:
    //Tab Key handler
    var keyListener:Object = new Object();
    keyListener.onKeyDown = function() {
    	if(Key.isDown(Key.TAB))
    	{
    		if(Key.isDown(Key.SHIFT))
    		{
    			_root.voucher.prev_text_box();
    
    		}else
    		{
    			_root.voucher.next_text_box();
    		}
    	}
    };
    Key.addListener(keyListener);

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    From what I understand, all you need is using the tabIndex property for the text fields you want to tab trough.

  3. #3
    Member
    Join Date
    Jan 2007
    Posts
    41
    Quote Originally Posted by nunomira
    hi,

    From what I understand, all you need is using the tabIndex property for the text fields you want to tab trough.

    Correct! Just want to let you know that in javascript there is a function called stopPropogation which does this.. Flash has something similar... SOrry Im very very new to flash.

  4. #4
    Senior Member
    Join Date
    Nov 2000
    Posts
    150
    Quote Originally Posted by nunomira
    hi,

    From what I understand, all you need is using the tabIndex property for the text fields you want to tab trough.

    Thanks Guys,

    nunomira, actually I'm using the Tab to move to a new frame as well as select text in an input text box.

    What is currently happening when I press "TAB" is that it cycles through selecting text boxes and then selects other objects like buttons etc. I want to stop the default "TAB" action from selecting objects so that I can dictate what occurs.

    The reply from 'kaliopi' is more what I'm looking for but I can't find it anywhere.

    Regards,
    Alan

  5. #5
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Ok,

    In this case, instead of restincting the tab to those text fields, disable it from all the other objects using the tabEnabled property.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center