Code to call a function when enter key is pressed

hi all,
In a table control program i need to call a function when i press enter key...
but im not able to do that since the function is always called when i press a push button on the screen.... can any one help me in this.. please....

Hi John,
      You are not getting any value in SY-UCOMM when you press "Enter",because the function code is not set for 'Enter" key in "Function Key" of the GUI-STATUS..
First define some fucntion code say 'ENT' for the Enter button available in "Fucntion key" of the GUI status.Once you done and activate the program and test it.The function code which u defined will be coming to SY-UCOMM field when you press 'ENTER" button and you can handle the various fucntionality whichevcer you want on "ENTER" .
Eg:
case sy-ucomm.
When 'ENT'.
Endcase.
Regards,
Vigneswaran S

Similar Messages

  • Default button being clicked multiple times when enter key is pressed

    Hello,
    There seems to be a strange difference in how the default button behaves in JRE 1.4.X versus 1.3.X.
    In 1.3.X, when the enter key was pressed, the default button would be "pressed down" when the key was pressed, but wouldn't be fully clicked until the enter key was released. This means that only one event would be fired, even if the enter key was held down for a long time.
    In 1.4.X however, if the enter key is pressed and held for more than a second, then the default button is clicked multiple times until the enter key is released.
    Consider the following code (which is just a dialog with a button on it):
    public class SimpleDialog extends JDialog implements java.awt.event.ActionListener
    private JButton jButton1 = new JButton("button");
    public SimpleDialog()
    this.getContentPane().add(jButton1);
    this.getRootPane().setDefaultButton(jButton1);
    jButton1.addActionListener(this);
    this.pack();
    public void actionPerformed(ActionEvent e)
    if (e.getSource() == jButton1)
    System.out.println("button pressed");
    public static void main(String[] args)
    new SimpleDialog().show();
    When you compile and run this code under 1.3.1, and hold the enter key down for 10 seconds, you will only see one print line statement.
    However, if you compile and run this code under 1.4.1, and then hold the enter key down for 10 seconds, you will see about 100 print line statements.
    Is this a bug in 1.4.X or was this desired functionality (e.g. was it fixing some other bug)?
    Does anyone know how I can make it behave the "old way" (when the default button was only clicked once)?
    Thanks in advance if you have any advice.
    Dave

    Hello all,
    I think I have found a solution. The behaviour of the how the default button is triggered is contained withing the RootPaneUI. So, if I override the default RootPaneUI used by the UIDefaults with my own RootPaneUI, I can define that behaviour for myself.
    Here is my simple dialog with a button and a textfield (when the focus is NOT on the button, and the enter key is pressed, I don't want the actionPerformed method to be called until the enter key is released):
    package focustests;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    public class SimpleDialog extends JDialog implements java.awt.event.ActionListener
    private JButton jButton1 = new JButton("button");
    public SimpleDialog()
    this.getContentPane().add(new JTextField("a text field"), BorderLayout.NORTH);
    this.getContentPane().add(jButton1, BorderLayout.SOUTH);
    this.getRootPane().setDefaultButton(jButton1);
    jButton1.addActionListener(this);
    this.pack();
    public void actionPerformed(ActionEvent e)
    if (e.getSource() == jButton1)
    System.out.println("button pressed");
    public static void main(String[] args)
    javax.swing.UIManager.getDefaults().put("RootPaneUI", "focustests.MyRootPaneUI");
    new SimpleDialog().show();
    and the MyRootPaneUI class controls the behaviour for how the default button is handled:
    package focustests;
    import javax.swing.*;
    * Since we are using the Windows look and feel in our product, we should extend from the
    * Windows laf RootPaneUI
    public class MyRootPaneUI extends com.sun.java.swing.plaf.windows.WindowsRootPaneUI
    private final static MyRootPaneUI myRootPaneUI = new MyRootPaneUI();
    public static javax.swing.plaf.ComponentUI createUI(JComponent c) {
    return myRootPaneUI;
    protected void installKeyboardActions(JRootPane root) {
    super.installKeyboardActions(root);
    InputMap km = SwingUtilities.getUIInputMap(root,
    JComponent.WHEN_IN_FOCUSED_WINDOW);
    if (km == null) {
    km = new javax.swing.plaf.InputMapUIResource();
    SwingUtilities.replaceUIInputMap(root,
    JComponent.WHEN_IN_FOCUSED_WINDOW, km);
    //when the Enter key is pressed (with no modifiers), trigger a "pressed" event
    km.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER,
    0, false), "pressed");
    //when the Enter key is released (with no modifiers), trigger a "release" event
    km.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER,
    0, true), "released");
    ActionMap am = SwingUtilities.getUIActionMap(root);
    if (am == null) {
    am = new javax.swing.plaf.ActionMapUIResource();
    SwingUtilities.replaceUIActionMap(root, am);
    am.put("press", new HoldDefaultButtonAction(root, true));
    am.put("release", new HoldDefaultButtonAction(root, false));
    * This is a copy of the static nested class DefaultAction which was
    * contained in the JRootPane class in Java 1.3.1. Since we are
    * using Java 1.4.1, and we don't like the way the new JRE handles
    * the default button, we will replace it with the old (1.3.1) way of
    * doing things.
    static class HoldDefaultButtonAction extends AbstractAction {
    JRootPane root;
    boolean press;
    HoldDefaultButtonAction(JRootPane root, boolean press) {
    this.root = root;
    this.press = press;
    public void actionPerformed(java.awt.event.ActionEvent e) {
    JButton owner = root.getDefaultButton();
    if (owner != null && SwingUtilities.getRootPane(owner) == root) {
    ButtonModel model = owner.getModel();
    if (press) {
    model.setArmed(true);
    model.setPressed(true);
    } else {
    model.setPressed(false);
    public boolean isEnabled() {
    JButton owner = root.getDefaultButton();
    return (owner != null && owner.getModel().isEnabled());
    This seems to work. Does anyone have any comments on this solution?
    Tjacobs, I still don't see how adding a key listeners or overriding the processKeyEvent method on my button would help. The button won't receive the key event unless the focus is on the button. There is no method "enableEvents(...)" in the AWTEventMulticaster. Perhaps you have some code examples? Thanks anyway for your help.
    Dave

  • Process PBO and PAI when Enter key is pressed

    Hello everyone,
    I am making a program where there is a I/O Box component. When the user enters data in this field and hits the 'ENTER' key I want to process the PBO and the PAI of that screen.
    The problem is what should i assign in the ok_code for this?
    Please advise.
    Thanks in advance,
    Karan

    >
    Karan Kappal wrote:
    > Hello everyone,
    > I am making a program where there is a I/O Box component. When the user enters data in this field and hits the 'ENTER' key I want to process the PBO and the PAI of that screen.
    > The problem is what should i assign in the ok_code for this?
    >
    > Please advise.
    >
    > Thanks in advance,
    > Karan
    You want to Go when user Press enter.
    In PBO we will set the status,
    SET PF-STATUS 'STATUS'. " double click on it or Go to SE41
    here activate the Function code for the ENTER button.
    in the FUnction keys you can see in the Beginning First Function (Green Tick mark) Give the Function code say ENTER , and give all necessary details and Activate .
    Now Test your application.
    When your enter the data and press enter, First it Goes to PAI
    here you do what ever required based on the action code...
    in PAI
    case ok_code.
    when 'ENTER'.
    "your code here...
    endcase.
    and once it is done, Control backs to PBO ..

  • First Text field in page submits when Enter key is hit. Don't want Submit

    Hi,
    I have searched and can't find this answer I got before...
    The Text field does not have the Submit always when pressed included, just a standard Text Item.
    because it is the first text field in the page.. or maybe it was because its the only text field on the page that causes it to "Submit" the page when the "Enter" key is pressed.
    I do not want the Enter key to Submit the page.
    Was it to add a dummy hidden text field before this text field?

    Awesome... I just found a post also with same answer!
    Thank you very much!
    http://djmein.blogspot.com/2007/04/stop-page-submission-when-enter-is.html

  • Web Interface - Call a function when web interface starts

    Hello,
    my problem is to call a function (fox formula) when the web interface starts. This function may execute only once.
    Can somebody help me?
    Thanks
    Stefan

    Hi,
    1. Create a custom class ZCL_BPS in SE24 inheriting the properties from superclass CL_UPWB_BSP_APPL.
    2. Redefine the method LOAD of this class ZCL_BPS and call your FOX formula over here using function module API_SEMBPS_FUNCTION_EXECUTE.
    eg. code
    METHOD LOAD .
    TRY.
    CALL METHOD SUPER->LOAD
      EXPORTING
        APPLICATION_NAME = APPLICATION_NAME
      RECEIVING
        APPLICATION      =  APPLICATION.
    CALL FUNCTION 'API_SEMBPS_FUNCTION_EXECUTE'
      EXPORTING
        I_AREA           =  'ZAREA01'
        I_PLEVEL         =  'LEVL001'
        I_PACKAGE        =  'PACK001'
        I_FUNCTION       =  'PFUN001'
        I_PARAM          =  'FOXF001'.
    ENDTRY.
    ENDMETHOD.                    "LOAD
    3. Replace CL_UPWB_BSP_APPL  by ZCL_BPS in the Application Class property of your Web Interface.
    This works for sure.
    Please grant points if it solves your purpose.
    Regards,
    Deepti

  • Call JavaScript function when my Condition is true in JSP

    Hi all,
    in my jsp i wanna call a javascript function (user defined) when a particular condition si met. How to go about it ? Can anyone plz help me out. Help appreciated.

    hi
    yes! we can do it as follows:
    in the JSP code u can include the javascript function
    first u declare the Javascript function before the </head> tag in the HTML
    and in the JSP u can just call the function which is as follow:
    <script>call the JavaScript function()</script>
    for example:
    <html>
    <head>
    <script language="JavaScript">
    function sayhi() {
    alert("hi");
    </script>
    </head>
    <body>
    <%
    zStr = request.getParameter("str");
    if(zStr.equals("true")) {
    %>
    <script>sayhi();</script>
    <%
    else {
    %>
    </body>
    </html>

  • How to call jquery function when i close modal dialog box ?

    Hello,
    I need to call one jquery function when I click on close button of modal dialog box.Can anyone please let me know how can I implement it ?
    Thanks,
    Dipti Chhatrapati

    Hi Dipti,
    If my understanding is correct, you are using SP Modal Dialog and want to track the close event of this dialog. Then you may use
    dialogReturnValueCallback parameter of Options variable. Follow is the code sample:
    function ShowModal() {
        ExecuteOrDelayUntilScriptLoaded(function () {
            var options = {
                url: 'page1.aspx',
                tite: 'Add Title',
                width: 800,
                height: 450,
                allowMaximize: true,
                showClose: true,
                dialogReturnValueCallback: scallback
            SP.UI.ModalDialog.showModalDialog(options);
        }, 'sp.js');
     function scallback(dialogResult, returnValue) {
          if (dialogResult == SP.UI.DialogResult.OK) {
               // call your Jquery method here...
    Thanks, Ram

  • Altering function will block calling this function when concurrency?

    Hi
    I would alter a function dynamically in a procedure,when altering function and calling this function occur at the same time,will it generate a blocking?
    thanks in advance

    Yes. If the function is being called and its running then the ALTER STATEMENT to such function will be in suspended mode until the execution of the function completes.
    However I cannot understand why would you want to modify a function in a stored procedure. You can always write a condition based function to perform different tasks on different conditions.
    Let us know the complete requirement and may be we can suggest some other alternatives.
    Please specify your SQL Server version while posting questions
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    thank you very much for your reply.
    My requirement is like below:
    In our existed system,there is one Employee table,now every user logining in system can see all employees in Employee table.
    Now we want to control users see specific employees meeting some conditions which are configurable in system.
    To minimize the effect on existed codes,we plan to rename Employee table to EmployeeTbl and create a  called Employee view in which EmployeeTbl joins the generated function which contains the sql generated by configured conditions for different users.
    I have finished the test,and it'ok,but I don't know whether it affects performance too much.
    Why not have a table to determine access groups ie what rows a employee can have access to (like say only immediate reportees for supervisors etc) and then link it to your existing users (AD logins). Then its just a matter of dtermining what group the executing
    user is part of and then using relationship set for group to determine whch all employees data he can view.
    The concept will look like this
    http://blogs.wrox.com/article/filtering-user-specific-report-data-in-sql-server-reporting-services/
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to call javascript function when form load[like onload="fun()" in html]

    I have to call javascript function at the time of iview is loading. I am not able use onload event which is not working in SAP Portal environment. Please suggest me any other alternative to call the function at the time of iview is loading. I have to set some properties when form is loading.

    I will explain my scenario correctly
    Let us take two pages
    1. Main Page (A)
    2. Child page (B)
           I have displayed records in tableview and each having checkbox and two buttons "print" and "viewDetails"  at down in page A. If I clicked "print" button the records which i have selected checkboxes details will be displayed in new window( page B). In page B i have given this following code
      <script language="javascript">
          window.opener.setTarget('Search');
      </script>
    setTarget() function is in page A.
    function setTarget(opt) {
      if(opt=='print')
         opt="";     
         document.<%=strFormControl%>.target="_blank";
       else
            document.<%=strFormControl%>.target="_self";
    This code is executing after the content of all records details displayed.
    My condition is If i click print button new window is opened and details are displaying. And before displaying content in new page B (means after opened new window) if i click on "viewDetails" button that is also opening new window because <script> code is not executed not yet. but it should display in same window when i click "viewDetails" button.

  • Call a function when the active document is closed

    Hi friends
    I have a portion of my script (at true a specific function) that I´d need to be executed every time the user close the app.activeDocument in Photoshop.
    I know there´s a Photoshop script called "Script Event Manager" where we can associate actions and scripts with events (like closing the document). I´d not like to use this script because..as I told...it´s not my entire script to be runned when closing a file..but only a function.
    Tried to search in the Script Event Manager for any event called "onClose" () but sure there´s nothing.
    How could I insert an event in the body of my own script that calls a function every time user close the active document?
    Thank you a lot for the help
    Best Regards
    Gustavo.

    As I said before the close event is really not that useful. In addition to the document already being closed the event descriptor will only have the path to the closed file if it was saved as part of the close event.
    But if you want to play around with this to see if it will be helpful to you here is one way. You will need to add the notifer. This only needs to be done once unless it is removed.
    app.notifiersEnabled = true;
    app.notifiers.add( "Cls ",new File('~/desktop/closeEventHandler.jsx') );
    Then for the event handler script, something like this.
    try {
        if (arguments.length >= 2) {
        var filePath;
        var desc = arguments[0];
        if( desc.hasKey( stringIDToTypeID('in') ) ) filePath = desc.getPath(stringIDToTypeID('in'));
        if( filePath != undefined ) alert( decodeURI( filePath ) );
    } catch (e) {}

  • Call a Function when switching tabs in TabbedPanel

    I am using Allan Jardine's DataTables javascript library , along with the Spry TabbedPanel. I have one table in each of a number of Tabs. The table in the tab opened by default (or if I use ShowPanel()) is fine. However, if I switch tabs, the other tables, which were hiden when the page was opened,  are not correctly initialised, and don't display correctly. Doing anything that causes the displayed table to be redrawn results in the table displaying correctly, and from then on I can switch tabs and the tables are fine.
    DataTables has an API function fnDraw(), which will cause a specified table to be redrawn. Is it possible to cause TabbedPanel to call a user specified function when the tabs are swapped, so I can call fnDraw()? I think this woiuld solve my problem.
    Thanks
    Ron

    Thanks.
    But I found a simpler way. At the end of the jQuery(document).ready(function(), which initialises the datatables, I added
    var ret=TabbedPanels1.showPanel("expiredquotes");
    oTable2.fnDraw();
    var ret=TabbedPanels1.showPanel("confirmedquotes");
    oTable3.fnDraw();
    var ret=TabbedPanels1.showPanel("openquotes");
    Which opens each of the "other" tabs and redraws the respective DataTable while they are "visible". Then at the end I display the 'default' Tab. I only need to do this once, when the page is opened, after which the tables are correctly formatted.
    Regards
    Ron

  • 'Confirm before sending SMS' when enter key is pre...

    Many will agree with me,
    While creating SMS we press 'Enter key' for next line, and then we realise that incomplete SMS has been sent and we got charged for it.
    There should be checkbox in Skype's Settings/Preferences for Messegeing:
    [√] "Confirm before sending SMS"
    Please push this feature if you agree with me.
    Thanks,
    Nitin

    The text of the submit button is transmitted to tell you which submit button was clicked, so naturally it doesn't send it if you don't click that button.
    The usual trick is to create an field like <INPUT TYPE="hidden" id="actionfield" name="action" value="enter">
    When an element that causes a submit, like clicking a button, happens then Javascript sets the value of the field to indicate the entry method. e.g.
    onClick="document.getElementById('actionField').value='ok'; return true"
    Obviously if the submit occurs due to hitting ENTER the action parameter will be "enter".
    Actually few forms use submit buttons these days because they look a bit clunky, most use images for buttons and power them with JavaScript.

  • Tableview: Call Javascript-Function when row is selected

    Hi everybody,
    I have created a tableview with selectionmode lineedit.
    Now, I'm looking for a way to call a Javascript function when a row is selected.
    The value of the selected row shall be passed to this function.
    How can I sove this.
    Best regards
    Alberto

    HI Alberto,
    referr to JavaScript to check if any row is selected or not..!...
    Even I am waiting for an answer...Now atleast I have a partner in th wait..!!
    Thanks,
    Tatvagna...

  • How to call java file when entering the another jsp page.

    when i click the link to link to another page, when enter the page, how can i call java file and passing id parameter to call method, which is connected to DB.
    when enter the page, how can i call java file together with one arguement???

    I would strongly suggest to go the MVC way. Please perform all DB operations through a Servlet/Action instead of directly hitting the JSP and then invoking a java bean to do the DB operation. JSP should only do the rendering.

  • No key event when compose keys are pressed

    I am supporting a legacy application for Sabre which maps some of the keys differently. For example, on a French keyboard the Compose key which is used to put a ^ on top of the vowel characters is to be remapped to produce a special character called a "Change Character" that has a special use for reservation agents that use Sabre
    The problem is, the first time you press the ^ compose key there is no key event apparently because the VM figures it doesn't yet know what key to report, it is expecting you to press a character such as 'o' and then you get an 'o' with a '^' on top of it.
    If you press the ^ compose key a second time, you get the following key events:
    keyPressed
    keyTyped
    keyTyped
    keyReleased
    On the screen you will see two ^ characters appear. Currently I remap the ^ character to the "Change Character", and I suppress the second keyTyped event so that I only get one character. The problem is that the user ends up having to press the key twice to get one "Change Character."
    I have no fix for this problem because there is no key event produced when they press the ^ compose key the first time.
    By the way, this behavior appears to have been introduced with jdk 1.3. The older jdk did produce a key event the first time you pressed the compose key. I would expect that this behavior was considered to be a bug and was fixed in jdk 1.3.
    Is there some other way to detect when the user presses a compose key? If not, is it possible for future jdk releases to report a keyPressed event when a compose key is pressed? This event would not cause a character to appear on the screen, but would allow programs to detect when the compose key is pressed.
    There is already a key on the French keyboard that behaves this way. It is the key to the left of the '1' key and it has the pipe symbol on it. If you press Shift plus this pipe key, no character is produces but a keyPressed event with a keycode of 222 is produced. I merely point this out to show that there is a way to report key events whithout producing output on the screen.
    Thanks, Brian Bruderer

    I don't know if this actually helps, but it seems that you can bind an Action to a dead key like the circumflex of the French keyboard
    Keymap keymap = textPane.addKeymap("MyEmacsBindings", textPane.getKeymap());
    Action action = getActionByName(DefaultEditorKit.beginAction );
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_DEAD_CIRCUMFLEX);
    keymap.addActionForKeyStroke(key, action);I saw this on a Swing tutorial and modified it slightly. Have a look at it :
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html
    Chris

Maybe you are looking for