dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: changing text fields with down and up keys

  1. #1
    graphic designer
    Join Date
    Aug 2002
    Location
    Brazil
    Posts
    112

    changing text fields with down and up keys

    How to capture the DOWN and UP keypresses when the
    cursor is inside text field?
    Im using
    code:
    onEnterFrame = function () {
    if (Key.isDown(Key.DOWN)) {
    Selection.setFocus(second_txt_instance);
    }
    };

    but it don't afect anything because the cursor is activing
    the text writting.
    what can I do?
    tks
    |calve|brazil|

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    you could use something like this,

    code:

    text1.onKeyUp = function() {
    if (eval(Selection.getFocus()) == this) { // if text1 has keyboard focus
    if (Key.getCode() == Key.DOWN) { // and the down arrow was pressed
    Selection.setFocus(text2); // focus the next textfield
    Selection.setSelection(0, 0);
    }
    }
    };
    Key.addListener(text1); // allow text1 to respond to the onKeyUp event



    where text1 and text2 are the instance names of the textfields.

  3. #3
    graphic designer
    Join Date
    Aug 2002
    Location
    Brazil
    Posts
    112
    very thank you catbert.
    I released some modifications to capture esc and enter keys,
    but it worked good!
    |calve|brazil|

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