How to activate a button with Enter key?

Hi
I was certain that in AC3 this is done by default, when the button is in focus and the ENTER key is press, it dispatches a Click event.. but it doesn´t work, am I missing something?? Thanks for your help.
myButon.addEventListener("click", funClick);
function funClick(evtObj:Event):void {
trace("yes");

if you have btnNum buttons with names btn1, btn2,... and they each have a listener function f1(), f2(), ...  you can use the following to code for them all and the enter key:
var btnNum:uint=2;
for(var i:uint=1;i<=btnNum;i++){
    this["btn"+i].addEventListener("click", this["f"+i]);
    this["btn"+i].addEventListener(MouseEvent.MOUSE_OVER,overF);
    this["btn"+i].addEventListener(MouseEvent.MOUSE_OUT,outF);
stage.addEventListener(KeyboardEvent.KEY_DOWN,f);
function overF(e:MouseEvent){
    stage.focus = InteractiveObject(e.currentTarget);
function outF(e:MouseEvent){
    stage.focus = null;
function f(evtObj:KeyboardEvent):void {
    if(KeyboardEvent(evtObj).keyCode==13 && stage.focus != null){
        stage.focus.dispatchEvent(new Event("click"));
// define your f1(), f2() etc functions

Similar Messages

  • How to select tree node with enter key instead of mouse click

    hia i have tree in forms 10g i can get node value when i click mouse on node but i want same with enter key which is not working any idea.
    thanx

    I'm afraid you have hit Bug 4509399
    If you have metalink access you should check Note:331369.1
    This bug has been around for the 10g R2 10.1.2.0.2 base release, which was propagated from Installing Patch 9.0.4.2 or from 10g R1 base release. You need to apply the latest patch or a one-off fix Patch 4509399
    Tony

  • How to activate hold button in MIGO ?

    Dear all,
    How to activate hold button in MIGO Screen ?
    Jeyakanthan

    Note 316931 - MIGO: 'Hold data' does not work
    Summary
    Symptom
    The function 'Hold data' is not active in Transaction MIGO.
    Additional key words
    Enjoy
    Cause and prerequisites
    This is caused by a program error.
    Solution
    Set the attribute 'Hold data' in the Screen Painter (Transaction SE51) for program SAPLMIGO in all screens. Generate the screen after you made the change. The functions are then available.
    You do not need to implement the changes manually if you import Support Packages.
    A prerequisite is that Note 303091 exists in your system.
    Manage held data
    You can use this function to hold the data you are currently entering. No documents are posted.
    To retrieve this data, choose "Goods receipt -> Held data". When retrieving the data, the held data is deleted from the overview tree.
    If you want to delete held data that is no longer required from the overview tree, you can select this data with "Goods receipt -> Held data".
    It is also possible to use held data as a reference for frequently recurring transactions, that will not be deleted after being called again.
    Caution:
    Some data cannot be held by the system and has to be re-entered after you try to retrieve it. This data includes:
    Batch classification
    Import data
    Profitability segment
    In Batch Classification, newly created selection criteria is lost if you do not post the document immediately.
    Edited by: sudhansu satapathy on Mar 4, 2010 9:19 AM
    Edited by: sudhansu satapathy on Mar 4, 2010 9:21 AM

  • Hi there, can anyone tell me how to activate my iphone with 2g network?

    hi there, can anyone tell me how to activate my iphone with 2g network?

    hi buddy, thnks for coming out to help me. so here we go.
    im using a vodafone connection and i made a dupilcate of that connection and made a nanao sim the will suit in iphone.
    after inserting its showing "To activate iphone"
    and below that 2 buttons are given as
    Try using Wi-Fi
    Try again over cellular
    and i dont have a wifi connection.
    but i have 2g connection in my number.
    on the top of iphone there is an "E" beside the range bars. obvioulsy might be Edge.
    When im selecting Try again over cellular then its showing could not activate.:(

  • Submitting form with Enter key

    Hello,
    in standard html form, when you have form with submit button, the enter key when any form element is selected submits the form.
    This is very convenient for users, so I want this with UIX forms. I know it is possible (I have one form where it is working), but I can't get it working anywhere else.
    This code works:
    <uix:form method="post" name="newRoleForm">
    <uix:inlineMessage prompt="Role name">
    <uix:textInput name="newRoleName" />
    <uix:spacer width="15" />
    <uix:submitButton text="Create" formName="newRoleForm" />
    </uix:inlineMessage>
    <uix:formValue name="jboEvent" value="newRole" />
    </uix:form>
    When I copy this code to another page, it does not work...
    Can somebody help, please?

    I've studied the HTML generated by UIX and it has following bugs and misfeatures:
    1. Misfeature: Submitting with Enter works ONLY if there is exactly one text field in the form (no submit button is actually needed), as Brian Stoler wrote. I don't understand reason for this.
    2. Bug: UIX generates javascript function "_submitOnEnter" which is called as event handler for "onKeyPress" event. But this function is erroneously generated multiple times, once for each form in the page. Browsers (Mozilla and IE) use the latest implementation. This function is different for forms with one text field and for forms with more text field, but only the first one can do the job. As a consequence of this, Enter can submit the form only if the last form on a page has single text field (which is for example not the case of search form with single field above another form...)
    Tested with UIX 2.1.7 in JDeveloper 9.0.3.3, using UIX as JSP tag library.
    Workaround:
    1. Use Opera browser: it submits form with enter key even if there is no submit button (this does not work for the first text field in the form, because it has "onkeypress" event handler).
    2. Implement this feature by hand yourself, if you really need it (see below).
    3. Use accessKey: allows to submit form with Alt+<key> combination (followed by Enter with IE).
    Implementing Enter key submits with Javascript:
    1. Put the following function to the header (or to javascript library):
    function enter(e, frm) {
    var kc;
    if(window.event) kc=window.event.keyCode;
    else if(e) kc=e.which;
    else return true;
    if(kc==13) {
    submitForm(frm,1);
    return false;
    Function copied from UIX (C).
    2. Add this event handler to each input element:
    onKeyPress="return enter(event, 'formName');"
    It is obvious that this is error prone, but it works with all browsers...
    Will this be fixed in future versions?
    Why only form with one text field can be submitted?

  • How can I arrange for the Enter key to just drop d...

    How can I arrange for the Enter key to just drop down a line instead of posting the message?

    In Skype go to Tools -> Options -> IM settings -> Show advanced options. In the section “Pressing Enter will” select the option: Insert line break.
    Note that this option is only available with Skype version newer than 6.1. The currently latest Skype version is 6.3.0.107.

  • How to associate a button with the selection/unselection of a JTable?

    hi,
    how to associate a button with JTable in this manna? i want to disable a button once there is no selection in the JTable, and enable the button when there is a selection. to associate the selection it is easy: just make an eventAction for the button on the click in the JTable and check whether there is a selection. but how to do this with the unselection? hope anyone can give me any hint. thanx!

    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test extends JFrame {
        String[] head = {"One","Two","Three"};
        String[][] data = {{"1-1","1-2","1-3"},{"2-1","2-2","2-3"},{"3-1","3-2","3-3"}};
        JTable jt = new JTable(data,head);
        public Test() {
         setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
         Container content = getContentPane();
         content.add(new JScrollPane(jt));
         jt.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
             public void valueChanged(ListSelectionEvent lse) {
              if (lse.getValueIsAdjusting()) return;
              if (jt.getSelectionModel().isSelectionEmpty()) {
                  System.out.println("Nothing Selected");
              } else {
                  System.out.println("Something Selected");
         setSize(500,500);
         show();
        public static void main( String args[] ) { new Test(); }
    }

  • How to activate ipod touch with no apple id

    how to activate ipad touch with no apple id &password i don't have proof of purchase

    Can't be done. You need an internet connection to activate an iPod after restoring.
    If your restore via wifi (settings>General>Reset>Erase all setting and connect) yo either need to connect to the internert via wifi or connect to a coputer and setup via iTunes. The computer requires an internet connection
    - If you restore via iTunes
    iTunes: Restoring iOS software
    The computer needs an internet connection

  • How do I enable the "fn  + enter" key to work as an "insert" function for windows on my mac laptop?

    how do I enable the "fn  + enter" key to work as an "insert" function for windows on my mac laptop?

    enable /disable function within the Bootcamp control panel within Windows Vista or 7

  • How to activate iPad air with t-mobile

    how to activate iPad air with t-mobile service

    Contact t-mobile where you are. Probably easiest to go to one of their
    stores or kiosks to sign up for a data plan and get an appropriately sized
    sim.

  • How to activate a JButton with right-click?

    If I create a JButton and add an ActionListener, I can activate the button with a mouse left-click but not with a mouse right-click.
    I've looked at other posts related to this topic. Some people have said that the default is that either a left- or right-click will activate a JButton but I can't get this to happen.
    If I add a MouseListener to the button, I get mouse events for both left and right clicks (in mousePressed() for instance) but only the left-click goes on to activate the JButton.
    I'm using Java 1.4 with Windows 2000.
    Thanks in advance for any help.
    -Rick

    I use Windows 98, that's what I get too. I'm pretty sure that's normal behavior. If you want right clicks to be processed as well, use this code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class BothClick extends JFrame implements MouseListener
        JButton clickMe;
        public BothClick()
            super("Test");
            setSize(300, 300);
            clickMe = new JButton("Click Me");
            getContentPane().setLayout(new FlowLayout());
            getContentPane().add(clickMe);
            clickMe.addMouseListener(this);
            setVisible(true);
        public void mousePressed(MouseEvent e)
            clickMe.doClick();
        public void mouseReleased(MouseEvent e) {}
        public void mouseEntered(MouseEvent e) {}
        public void mouseExited(MouseEvent e) {}
        public void mouseClicked(MouseEvent e) {}
        public static void main(String[] args)
            new BothClick();
    }

  • How to Activate "Caps Lock" and "Shift" keys using J buttons

    Hi
    I would like to know . how I can activate "Caps Lock", "Shift", "Esc" keys located on the keyboard using Jbuttons. Can you write the codes to me please. I will be greatfull
    Thanks
    Nalin

    You almost got there but it is setLockingKeyState and not setLockingState ..Never mind!!!!

  • Problem with Enter key and JOptionPane in 1.4

    Hi,
    I had a problem with an application I was working on.
    In this application, pressing [Enter] anywhere within the focused window would submit the information entered into the form that was contained within the frame.
    The application would then try to validate the data. If it was found to be invalid, it would pop up a JOptionPane informing the user of that fact.
    By default, pressing [Enter] when a JOptionPane is up will activate the focused button (in most cases, the [OK] button) thus dismissing the dialog.
    In JDK 1.3 this worked fine. But in JDK 1.4, this has the result of dismissing the dialog and opping it up again. This is because the [Enter] key still works on the frame behind the JOptionPane and thus tries to validate it again, which results in another invalid dialog msg popping up.
    The only way to get out is to use the mouse or the Esc key.
    Now, in the application I put in a workaround that I was not very happy with. So, to make sure it wasn't the application itself, I created a test which demonstrates that it still misbehaves.
    Here it is.
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.AbstractAction;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JTextField;
    import javax.swing.KeyStroke;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    import javax.swing.WindowConstants;
    * @author avromf
    public class FocusProblemTest extends AbstractAction
         private static JFrame frame;
         public FocusProblemTest()
              super();
              putValue(NAME, "Test");
         public void actionPerformed(ActionEvent e)
              JOptionPane.showMessageDialog(frame, "This is a test.");
         public static void main(String[] args)
              FocusProblemTest action= new FocusProblemTest();
              try
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch (Exception e)
                   e.printStackTrace();
              frame= new JFrame("Test");
              frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              Container contents= frame.getContentPane();
              contents.setLayout(new FlowLayout());
              JTextField field= new JTextField("Test");
              field.setColumns(30);
              JButton  button= new JButton(action);
              KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
              button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(enterKey, "test");
              button.getActionMap().put("test", action);
              contents.add(field);
              contents.add(button);
              frame.pack();
              frame.setVisible(true);
    }Does anyone have any solution to this problem?

    I know that focus management has changed alot.
    Based on my experimentation a while back, in 1.4 it still believes that the JFrame is the window in focus, even though a JOptionPane is currently in front of it (unless I misinterpreted what was going on). Thus, the frame seems to get the keyboard event and re-invoke the action.
    A.F.

  • Submit a Form in IE with Enter key.

    Hi all,
    I have a Form with a Get attribute, a textfield and a search
    (submit) button.
    When I press the Enter key in my keyboard, the form is not
    submited in I.E. (i'm using IE 7).
    When I click the button with the mouse, it works.
    In Firefox, all (keyboard and mouse) works.
    How can we workaround this issue?
    Thanks

    oicram wrote:
    > Please, I need an answer here. I have deeply search over
    the internet and I only found something about .js or hidden fields,
    but its all vague...
    http://www.webreference.com/programming/java_dhtml/chap8/2/2.html
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Buttons and enter key problem

    hello,
    there are a few projects of enterprise quality which I am developing in java swing. I found out through research that many or rather most people involved with java believe that swing is ready for enterprise class robust desktop applications.
    so I as the team leador am starting my new projects in java swing.
    I personally find that the amount of java libraries present provide a rich set of functionality and it gives big mussle power to the developers.
    I am only concerned about one problem which many of you might have solved.
    I find that I have to hit the space bar instead of enter key to fire an action. in languages like vb I can press enter key to fire the click events. specially in menu items I certainly don't expect my clients to press the spacebar. besides there are many people who are so used to the keyboard and enter key in particular that it will be hard or rather next to impossible to change their habbits.
    how can I make the menu items work with the enter key. I mean do I need to create the code for keypress events every time I also create an action performed method? or is there a way where I can do it without extra coding.
    it is just that I don't want to right extra code for enter key along with click events.
    one more important note.
    I am a blind person and I use the access bridge technology of java.
    so when I am involved in coding, I use the same.
    so may be my problem isn't a problem in the first place.
    kindly provide me some help
    thanks
    Krishnakant.

    The enter-key works on menu-items in all my applications. It did so since I started with java few years ago.
    Maybe some other problem (OS-specific) ?

Maybe you are looking for