Simulate arrow key events in labview

Hello,
I am trying to simulate the arrow key events (left, right, up & down) in labview. Lets say I would like the events to happend when a slider bar goes beyond a certain threshlold (later I will inteface it with a daq).
I found this example but, I can not figure out how to move the arrow keys (and I have not experiance with the User32.dll):
http://zone.ni.com/devzone/cda/epd/p/id/3711
I would really appreciate the help.
Many thanks
Solved!
Go to Solution.

Hi,
    I need to get multiple-key-press of arrow-keys. i.e., if I press Up-Arrow-Key, keep hold it down, while being pressed down press Left-Arrow-Key and keep it pressed(now both keys are pressed First: Up, Second: Left). Now my requirement is I need to get the following sequence of Key-Values -
Up-Key, Left-Key, Up-Key, Left-Key, Up-Key, Left-Key ...etc., 
as long as both keys are kept dow.
-Any help is appreciated
-Beginer

Similar Messages

  • KeyListener does not capture Arrow key Events in textField

    Love................
    I added a key listener to TextField it does not detect
    Arrow Keys events in keyTyped, KeyPressed,KeyReleased methods
    why?????
    I want to shift focus from a textfield to other component
    on capturing Arrow key Pressed How

    Here is a Java demo where it works since it is not a printable character you must get the keyCode:
    http://java.sun.com/docs/books/tutorial/uiswing/events/example-swing/index.html#KeyEventDemo
    public class KeyEventDemo ... implements KeyListener ... {
    ...//where initialization occurs:
         typingArea = new JTextField(20);
         typingArea.addKeyListener(this);
    /** Handle the key typed event from the text field. */
    public void keyTyped(KeyEvent e) {
         displayInfo(e, "KEY TYPED: ");
    /** Handle the key pressed event from the text field. */
    public void keyPressed(KeyEvent e) {
         displayInfo(e, "KEY PRESSED: ");
    /** Handle the key released event from the text field. */
    public void keyReleased(KeyEvent e) {
         displayInfo(e, "KEY RELEASED: ");
    protected void displayInfo(KeyEvent e, String s){
         char c = e.getKeyChar();
         int keyCode = e.getKeyCode();
         int modifiers = e.getModifiers();
         tmpString = KeyEvent.getKeyModifiersText(modifiers);
         ...//display information about the KeyEvent...
    }

  • Question: Inadvertently a visiting toddler gained access to my computer during a visit. He's obviously fiddled with something as I can no longer use my arrow keys to navigate through my albums or events on iPhoto. Please help!

    Question: Inadvertently a visiting toddler gained access to my computer during a visit. He's obviously fiddled with something as I can no longer use my arrow keys to navigate through my albums or events on iPhoto. Only one pic shows up in the album view - I can't see any thumbnails. To see the other pics I have to use the scroll bar on the right hand side of the window. Please help!

    Depeding on your version of iPhoto: On the left (iPhoto 11) or right (earlier versions) of the lower frame of the iPhoto Window you'll see a slider. Drag it left.
    Regards
    TD

  • Arrow key in the keydown event

    Hello,
    I used the keydown event to display the characters on the Screen depending on the key which is pressed,
    but if I press arrow keys and want to display "x" on the extreme right side of the characters for example :
    abcsdex
    here x is displayed when left arrow key is pressed. I tried it but x is not displayed where I want it is displayed on the extreme left of the characters or in between the characters.
    Thank you.

    I used the keydown event to display the characters on
    the Screen depending on the key which is pressed,
    but if I press arrow keys and want to display "x" on
    the extreme right side of the characters for example
    abcsdex
    here x is displayed when left arrow key is
    pressed. I tried it but x is not displayed where
    I want it is displayed on the extreme left of the
    characters or in between the characters.
    Thank you.write a KeyPressed event.get a ASCII value of the key you want to press.Then append the ASCII value of that pressed key to the current string in your desired position.First store the current string to a String variable.

  • Labview 2009 SP1 crashes when moving large selection with arrow key

    If I select a lot (10 or 15) of Block Diagram components and try to move them some distance with the arrow key, I will frequently get a program crash.  Since a smaller number of components seems to crash after a longer travel distance, it looks like some kind of buffer overflow error.  I do not see this problem when using the mouse to move selections.
    I have checked to be sure I have the latest video driver for my NVIDIA Quatro FX570.  I have also tried working with no hardware acceleration and no combined writes.  This is happening on Windows XP SP3 with all the current updates.
    It has become so bad that I have to do a Save As every fifteen minutes to keep from losing data.
    Why don't I use my mouse for all movements?  Because it is not as accurate and not so easy to restrict to one dimension of movement.   My hand is not as steady as it once was.
    I hoping someone will have a suggestion that will clear up this problem.
    Solved!
    Go to Solution.

    As I indicated, I had the same problem with 8.5 and just DID a new installation of Labview 2009.
    Since it is possible my three-monitor setup, which obviously requires more video memory, may be at the root of the problem, I am satisfied with the workaround of dragging the objects near their final destination and then using the arrow keys.  
    Three monitors are ideal for front panel, block diagram and Help/Internet/Probe Window.  When I had to work in the field with only one monitor, I felt severely handicapped.
    You may consider the matter closed.
    Thanks for attempting to duplicate the failure.

  • Simulate Key Event " "

    Does anybody know how to simulate keys that are only available while holding down the shift key? I have a VI that is based on an API that simulates key events, including the shift key. It works great. But I do not know how to get characters, such as ">", that are combinations of the shift key. It seems to me that just sending the code for the shift key and then the code for "." generates two events and only results in the "." since the shift key was not kept down... Any help in this issue is very welcome!! Thanks! /Mikael (LV 6.1)

    Look up an ASCII chart. The ASCII code for ">" is 62. There is a "keybd_event" function inside user32.dll. It's syntax is:
    void keybd_event(unsigned char bVk, unsigned char bScan, unsigned long dwFlags, unsigned long dwExtraInfo);
    Use the Call Library Function Node to call this function. Wire the ASCII code (62) to the first U8 input, and 0 to the next three inputs. This simulates the key being pressed. Then pause for a few milliseconds. Then call the function again, wire the ASCII code to the first U8, wire 2 to the first U32, wire 0 to the other U8 and U32. This simulates releasing the key. You can simulate any keystroke by using this function and the ASCII code. You must use it twice, once for key down and once for key up.
    - tbob
    Inventor of the WORM Global

  • Waveform graph plot legend in labview 8.5 won't respond to arrow keys?

    I heard labview 8.5 fixes most of the problems that plague 8.2, so I recently installed it to try it out and see if it is worth the effort of another upgrade.  Messing around today, I found an issue that wasn't related to the installer itself.
    The plot legend on a waveform graph doesn't appear to respond to arrow keys for precise placement.  It doesn't matter whether auto-size plot legend is turned on or off.  When I want to place a plot legend very precisely, just like with any other labview control I like to use the arrow keys to get things perfectly aligned.  I want to make the plot legend perfectly in the corner of the graph but its very hard to get it placed right with just the mouse.  In labview 8.5 it seems like plot legends no longer respond to arrow keys.
    Can anyone confirm this or know of a way to precisely place the plot legend in labview 8.5?
    -Devin
    I got 99 problems but 8.6 ain't one.

    Ben,
    I checked the snap to grid hypothesis. Even when activated the arrow keys still allow an accurate positionning of the objects at pixel level.
    That's so nice that I changed my setup. I now have a reasonnably large spaced grid (50 pixels) with an invisible grid (contrast adjusted to zero). That should make object positionning and dimensionning much faster than before.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Programmat​ic change in multicolum​n listbox value ignored by internal key event handler

    The attached LabVIEW 8.5 vi demonstrates a problem I noticed using multicolumn listboxes.  Upon changing the value (selected row) of the listbox programmatically, the very next press of the up or down arrow key behaves as if the value was never changed.  For example, if the 3rd row is selected and then the listbox value is changed programmatically via a local variable or the value property to select the 0th row, pressing the down arrow key should now select the 1st row, but instead the 4th row is selected.
    A workaround is to handle the Key Down? event myself as I've demonstrated in the attachment, but if this is a bug, I hope it can be corrected in a future release.
    Larry
    Attachments:
    MC Listbox Bug.vi ‏30 KB

    Hi Larry,
    Pnt is correct and this is a known bug and relates to how the current row/ active row is handled when changing the values programmatically.  Perhaps if you post your code we both can have a look and provide additional guidance.
    Alternatively this forum post is related to your work around for using the event handler.
    Regards,
    Rishi L
    National Instruments
    Applications Engineer

  • How to implement JSF text input down-arrow key = next record navigation?

    Hi All,
    I've got a small query which you experts might be able to help me through. I would not be surprised if such questions would already have been raised in this forum.
    Formerly, I've created an Oracle Form that allow user to quickly insert data in bulk. It only has three 3 fields - first name, second name and address. Because of the flexibility of the Oracle Form, by pressing the down arrow key, user is able to create record when the last record is detected. And vice versa by hitting the up arrow key, it will move to the previous record when the current record is not the first record. So basically, the form is very 'key-driven' and without the use of the mouse, a lot of data can be inserted very quickly and efficiently.
    I've successfully converted such form to an ADF BC JSF page using the JHeadstart toolkit. But when I showed it to my users for comment, they were really disappointed with the number of mouse interactions they need to click every time to navigate between records as well as creating new records. My question is can I build some sort of ADF JSF event handler on any of the text items to perform the following tasks:
    1.) When 'down arrow key' is pressed AND not the last record THEN
    Go to the next record.
    2.) When 'down arrow key' is pressed AND is the last record THEN
    Go to the next blank record.
    3.) When 'up arrow key' is pressed AND not the first record THEN
    Go to the previous record.
    4.) When 'up arrow key' is pressed AND is the first record THEN
    Do nothing.
    If all the four above tasks are achievable in ADF JSF, can you please guide and brief me on the steps to implement them. Or these functionalities are already available somewhere in other open source toolkits. Your help is much appreciated. Thank you and have a nice day.
    Kind Regards,
    John

    Hi Steven,
    I've tried to incoporated attached link's codes with the JHeadstart generated code inside the jspx but I still cannot get it to work. There is a lot of Javascript error and is impossible to debug.
    Regards,
    John

  • Arrow keys and enter key not functioning in Firefox 3.6 when viewing PDF

    I'm using Adobe Reader 9.3.0.
    I have a web application that displays PDFs (using Adobe Reader) in a browser.  The PDF is loaded onto the page inside an IFRAME.  In addition to the IFRAME containing a PDF, the page also includes several forms, text fields, etc. For the most part this is working fine.  However, I have a glitch when using this in Firefox 3.6. I'm finding that certain keyboard events are being lost and I strongly suspect that they are being swallowed by Adobe Reader.  When I place focus on an HTML text field and press enter key or arrow keys, I do not get the appropriate key events.  If I run the exact same test without the PDF IFRAME these key events work correctly, but as soon as I load the PDF into the IFRAME they do not.  I believe the primary key event that gets lost is the keydown event.  I do get the keyup event.
    Again, the events work correctly up until I load the PDF onto the page.
    I've verified that this error does not occur in Firefox 3.5 and 3.0.
    Here is a testcase to reproduce this:
    <html>
    <head>
        <title>JavaScript - Detecting keystrokes</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <script type="text/javascript">
            var pdfURL = 'http://samplepdf.com/sample.pdf';
            window.onload = function () {
                init();
            document.defaultAction = true;
            function init() {
                var x = document.getElementById('testForm').getElementsByTagName('input');
                for (var i=0;i<x.length;i++) {
                    x[i].onclick = setEvents;
                    if (x[i].checked)
                        x[i].onclick();
                writeroot = document.getElementById('writeroot');
                document.getElementById('emptyWriteroot').onclick = function () {
                    writeroot.innerHTML = '';
                    return false;
            function setEvents() {
                if (this.id == 'default') {
                    document.defaultAction = !this.checked;
                    return;
                var eventHandler = (this.checked) ? detectEvent : empty;
                document.getElementById('textfield')['on'+this.id] = eventHandler;
                //document['on'+this.id] = eventHandler;
            function detectEvent(e) {
                var evt = e || window.event;
                writeData('<b>'+evt.type+'</b>:  keyCode=' + evt.keyCode+' : charCode=' + evt.charCode);
                return document.defaultAction;
            function empty() {
                // nothing
            var writeroot;
            function writeData(msg) {
                writeroot.innerHTML += msg + '<br />';
        </script>
        <style type="text/css">
            body {
                font-size: 12px;
            #writeroot {
                height: 300px;
                overflow: auto;
                border: 1px solid #2EB2DC;
        </style>
    </head>
    <body>
    <form id="testForm">
    <input type="checkbox" id="keydown" /> <label for="keydown">keydown</label><br />
    <input type="checkbox" id="keypress" /> <label for="keypress">keypress</label><br />
    <input type="checkbox" id="keyup" /> <label for="keyup">keyup</label><br />
    <input type="checkbox" id="default" /> <label for="default">Suppress default action</label><br />
    <input type="text" id="textfield" /><br />
    <button id="emptyWriteroot">Remove messages</button>
    </form>
    <a href="#" onclick="document.getElementById('docviewer-page').src=pdfURL;return false">Now load IFrame</a>
    <p id="writeroot"></p>
    <div id="container2" style="border:1px solid black;width:400px;height:200px">
            <iframe
                id='docviewer-page'
                name='docviewer-page'
                title='document page'
                src='http://www.google.com'
                align='left'
                width='100%'
                height='100%'
                scrolling='auto'
                frameborder=0></iframe>
    </div>
    </body>
    </html>
    Paste the above into an HTML document.  Open the HTML document in Firefox 3.6.  Check the four checkboxes.  Move into the text field and press arrow keys and enter key to observe the results when it is working correctly.  Then click on the "Now Load PDF" link.  Press the arrow keys and enter key again and observe that the behavior has changed.
    Anybody have any idea why this is happening or how to work around it?

    I found a workaround!
    By using an object tag instead of an iframe, all the keys seems to work fine and the PDF still renders in the page the same way.
    Here's a page that works:
    <html>
    <head>
        <title>JavaScript - Detecting keystrokes</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <script type="text/javascript">
            var pdfURL = 'http://samplepdf.com/sample.pdf';
            window.onload = function () {
                init();
            document.defaultAction = true;
            function init() {
                var x = document.getElementById('testForm').getElementsByTagName('input');
                for (var i=0;i<x.length;i++) {
                    x[i].onclick = setEvents;
                    if (x[i].checked)
                        x[i].onclick();
                writeroot = document.getElementById('writeroot');
                document.getElementById('emptyWriteroot').onclick = function () {
                    writeroot.innerHTML = '';
                    return false;
            function setEvents() {
                if (this.id == 'default') {
                    document.defaultAction = !this.checked;
                    return;
                var eventHandler = (this.checked) ? detectEvent : empty;
                document.getElementById('textfield')['on'+this.id] = eventHandler;
                //document['on'+this.id] = eventHandler;
            function detectEvent(e) {
                var evt = e || window.event;
                writeData('<b>'+evt.type+'</b>:  keyCode=' + evt.keyCode+' : charCode=' + evt.charCode);
                return document.defaultAction;
            function empty() {
                // nothing
            var writeroot;
            function writeData(msg) {
                writeroot.innerHTML += msg + '<br />';
        </script>
        <style type="text/css">
            body {
                font-size: 12px;
            #writeroot {
                height: 300px;
                overflow: auto;
                border: 1px solid #2EB2DC;
        </style>
    </head>
    <body>
    <form id="testForm">
    <input type="checkbox" id="keydown" /> <label for="keydown">keydown</label><br />
    <input type="checkbox" id="keypress" /> <label for="keypress">keypress</label><br />
    <input type="checkbox" id="keyup" /> <label for="keyup">keyup</label><br />
    <input type="checkbox" id="default" /> <label for="default">Suppress default action</label><br />
    <input type="text" id="textfield" /><br />
    <button id="emptyWriteroot">Remove messages</button>
    </form>
    <a href="#" onclick="document.getElementById('docviewer-page').data=pdfURL;return false">Now load IFrame</a>
    <p id="writeroot"></p>
    <div id="container2" style="border:1px solid black;width:400px;height:200px">
            <object
                id='docviewer-page'
                name='docviewer-page'
                title='document page'
                data='http://www.google.com'
                align='left'
                width='100%'
                height='100%'
                ></object>
    </div>
    </body>
    </html>

  • Why do arrow keys stop working with type in CS6

    I searched this issue and found many forums discussing the topic, but no solution. When using PS CS6, the arrow keys randomly stop working when navigating around in text. This is extremely frustrating. Per other discussions, and my experience, there doesn't seem to be a constant trigger. Saving the PS file when it happens SEEMS to fix it - at least temporarily. It's been happening off and on since I upgraded.
    Adobe reps (they're say "employee") monitoring the photoshop.com forums suggested the fix is to close all other apps. No one works that way. Chrome (or other browsers) were speculated to be the cause. but I just had this happen without any browser open.
    Any insight would be greatly appreciated. It's the simple things that cause the most frustration.
    Sysytem details:
    CS6 upgrade form CS5 Premium
    Lion 10.7.4 / 16G / i7 Intel
    Safari / Chrome
    MS Office
    Mac Mail
    FontAgent Pro

    Nobody suggested that closing other apps was fix - that was just a test to determine which apps were causing problems with event handling that prevented Photoshop from correctly handling the key events.
    And if there were already posts on this topic, why did you create a new topic on the same thing?

  • Key Bindings using the arrow keys

    Following is some code that allows you to move a component around the screen using the arrow keys. I've noticed a problem and I'm just wondering if its Java or my keyboard.
    Lets start with an example that works:
    Press the down and right keys. Then press either the up or left key. The image moves proving that it supports 3 keys.
    Now for the problem:
    Press the up and left keys. Then press either the down or right key. Three things to notice:
    a) the direction doesn't change when the third key is pressed
    b) no output is displayed, so the ActionListener is not being invoked
    c) after a short time, the program starts beeping
    Now try rerunning the code after removing the comments that assign the key bindings to the "a, s, d, f" keys. Redo the above test and it works even if all four keys are pressed.
    I don't remember this problem when I wrote the code a while ago, but I did recently get a cheap new keyboard so I'm just wondering if the problem is my keyboard or whether its a quirk with Java.
    You can download Duke from here:
    http://java.sun.com/docs/books/tutorial/uiswing/examples/components/LayeredPaneDemoProject/src/components/images/dukeWaveRed.gif
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class KeyboardNavigationProblem implements ActionListener
         private JComponent component;
         private int deltaX;
         private int deltaY;
         private Timer timer;
         private int keysPressed;
         private InputMap inputMap;
         public KeyboardNavigationProblem(JComponent component, int delay)
              this.component = component;
              this.deltaX = deltaX;
              this.deltaY = deltaY;
              timer = new Timer(delay, this);
              timer.setInitialDelay( 0 );
              inputMap = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
         public void addAction(int keyCode, String description, int deltaX, int deltaY)
              new NavigationAction(keyCode, description, deltaX, deltaY);
         public void updateDeltaX(int delta)
              deltaX += delta;
         public void updateDeltaY(int delta)
              deltaY += delta;
         public void actionPerformed(ActionEvent e)
              int componentWidth = component.getSize().width;
              int componentHeight = component.getSize().height;
              Dimension parentSize = component.getParent().getSize();
              int parentWidth  = parentSize.width;
              int parentHeight = parentSize.height;
              //  Determine next X position
              int nextX = Math.max(component.getLocation().x + deltaX, 0);
              if ( nextX + componentWidth > parentWidth)
                   nextX = parentWidth - componentWidth;
              //  Determine next Y position
              int nextY = Math.max(component.getLocation().y + deltaY, 0);
              if ( nextY + componentHeight > parentHeight)
                   nextY = parentHeight - componentHeight;
              //  Move the component
              component.setLocation(nextX, nextY);
         class NavigationAction extends AbstractAction implements ActionListener
              private int deltaX;
              private int deltaY;
              private KeyStroke pressedKeyStroke;
              private boolean listeningForKeyPressed;
              public NavigationAction(int keyCode, String description, int deltaX, int deltaY)
                   super(description);
                   this.deltaX = deltaX;
                   this.deltaY = deltaY;
                   pressedKeyStroke = KeyStroke.getKeyStroke(keyCode, 0, false);
                   KeyStroke releasedKeyStroke = KeyStroke.getKeyStroke(keyCode, 0, true);
                   inputMap.put(pressedKeyStroke, getValue(Action.NAME));
                   inputMap.put(releasedKeyStroke, getValue(Action.NAME));
                   component.getActionMap().put(getValue(Action.NAME), this);
                   listeningForKeyPressed = true;
              public void actionPerformed(ActionEvent e)
                   if (listeningForKeyPressed)
                        updateDeltaX( deltaX );
                        updateDeltaY( deltaY );
                        inputMap.remove(pressedKeyStroke);
                        listeningForKeyPressed = false;
                           if (keysPressed == 0)
                                timer.start();
                     keysPressed++;
                   else // listening for key released
                        updateDeltaX( -deltaX );
                        updateDeltaY( -deltaY );
                        inputMap.put(pressedKeyStroke, getValue(Action.NAME));
                        listeningForKeyPressed = true;
                        keysPressed--;
                           if (keysPressed == 0)
                                timer.stop();
                   System.out.println(KeyboardNavigationProblem.this.deltaX + " : "
                   + KeyboardNavigationProblem.this.deltaY);
         public static void main(String[] args)
              JPanel contentPane = new JPanel();
              contentPane.setLayout( null );
              JLabel duke = new JLabel( new ImageIcon("dukewavered.gif") );
              duke.setSize( duke.getPreferredSize() );
              duke.setLocation(100, 100);
              contentPane.add( duke );
              KeyboardNavigationProblem navigation = new KeyboardNavigationProblem(duke, 100);
              navigation.addAction(KeyEvent.VK_LEFT, "zLeft", -5, 0);
              navigation.addAction(KeyEvent.VK_RIGHT, "zRight", 5, 0);
              navigation.addAction(KeyEvent.VK_UP, "zUp", 0, -5);
              navigation.addAction(KeyEvent.VK_DOWN, "zDown", 0, 5);
    //          navigation.addAction(KeyEvent.VK_A, "zLeft", -5, 0);
    //          navigation.addAction(KeyEvent.VK_S, "zRight", 5, 0);
    //          navigation.addAction(KeyEvent.VK_D, "zUp", 0, -5);
    //          navigation.addAction(KeyEvent.VK_F, "zDown", 0, 5);
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.setContentPane( contentPane);
              frame.setSize(800, 600);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }

    if you hold down left and right (so it doesn't move), down works, but not up.
    hold up/down, right works but not left.Yes, the problem only seems to be when the up and left in combination with the right or down key is pressed.
    num lock off - use the number pad arrow keys and all works OK Thats interesting, I didn't notice that. Although it just confuses the issue as to what the problem is.
    So it appears to me that:
    a) left + up + down, and
    b) left + up + right
    are special key combinations that are intercepted by either the OS or the JVM. Do these key combinations ring a bell to anybody?
    I'm use JDK1.4.2 on XP. I wonder if other OS will have the same problem?
    Again, this isn't a real, problem, just more of a curiosity. Thanks,

  • UP AND DOWN ARROW KEY HANDLING IN MODULE POOL PROGRAM

    HI GURUS,
    I HAVE A STRANGE REQUIREMENT ....I AM DISPLAYING  TWO TABLE CONTROLS IN A SCREEN
    WHERE IN THE 1ST TABLE CONTROL IS DISPLAYING ALL THE SALES ORDER NO'S  WHEN ENTER KEY IS PRESSED.
    THE SECOND TABLE IS DISPLAYING THE ITEMS FOR THE SELECTED SALES ORDER...
    THIS IS HAPPENING WHEN I DOUBLE CLICK THE SALES ORDER NO IN THE FIRST TABLE CONTROL..
    NOW THE CLIENT SAYS HE WILL NOT DOUBLE CLICK IT...HE SAYS THAT THE ITEM DISPLAY IN THE SECOND TABLE SHOULD BE DONE WHEN HE USES THE ARROW KEYS..

    Yes!
    Create a class like this:
    CLASS lcl_click_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
                       IMPORTING e_row_id e_column_id.
    ENDCLASS.             
    Write the implementation for this class which meets your needs.
    Declare it:
    DATA: obj_click_handler TYPE REF TO lcl_click_handler.
    Create and use it:
    CREATE OBJECT obj_click_handler.
    SET HANDLER obj_click_handler->handle_hotspot_click  FOR your_obj_grid.
    Regards
    Jordi

  • Artifacts when moving object with arrow keys.

    Hi all
    hope this is the right place to post this question.
    I want to to write simple arkanoid game in Flash (AC3). I've managed to write code that  moves my paddle with arrow keys. The code looks like this:
    function OnNewFrame(event:Event):void
        if (input.IsLeftHeld)
            if (paddle.x > 0)
                paddle.x -= 10;
        else
        if (input.IsRightHeld)
            if (paddle.x < stage.stageWidth - paddle.width)
                paddle.x += 10;
    It works but the result is ugly. The animation is not fluent, there are times when paddle stops for a moment . Also when speed of translation is high (here it is 10) you can see that paddle is flickering at the ends, it looks like single buffering problem. You can see both of those effects here:  http://www.flash-game-design.com/flash-tutorials/movOb.html , hovewer flickering is less visible due to small translation amount.
    How to fix this? How can i enable double buffering (or maybe it is enabled by default)?  Any help will be appreciated.
    P.S. sorry for bad english

    Thanks for samples, this is very kind ; p
    Hovewer you are doing everything almost exactly as I'am doing. Tou are using mySymbol.x++ which means your translation speed is 1. Also I'am aware that rising frame rate will result in smoother animations, but this is not the point. So once again, my flash applications suffer from two problems:
    1) Animations are not smooth. You can see this crealrly in here: http://www.kirupa.com/developer/actionscript/hittest.htm  , go back to the very bottom of the page, there is an animation window, look at the smallest circle. It looks like its blinking. 
    2) Moving symbols with arrow keys with the method i've presnted in the first post (the same method that infeter uses ). Moved symbol is randomly stopping for the very (very very) short amount of time. You can easily spot this in infeter sample.
    Many sample applications i've seen suffer from those issues. and nobody seems to see the problem, so maybe I am delusional? ; p
    cheers and thank for help

  • Moving shape with arrow keys

    Hello,
    How would I click on one of the circles I've created and move them using the arrow keys. The circles move just fine with the drag of the mouse but now I want to use the arrow keys. Can somebody help me please? I would really appreciate the assistance.
    Michael
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DragBallPanel extends JPanel implements MouseListener, MouseMotionListener, KeyListener
    private static final int BALL_DIAMETER = 50; // Diameter of ball
    private static final int BALL_DIAMETER2 = 50;
         //--- instance variables
    /** Ball coords. Changed by mouse listeners. Used by paintComponent. */
    private int _ballX     = 50;   // x coord - set from drag
    private int _ballY     = 50;   // y coord - set from drag
    private int x2 = 200;               // starting x coord for 2nd ball
         private int y2 = 200;               //starting y coord for 2nd ball
         private int x3 = 75;
         private int y3 = 150;
    /** Position in ball of mouse press to make dragging look better. */
    private int _dragFromX = 0;    // pressed this far inside ball's
    private int _dragFromY = 0;    // bounding box.
    private int xInsideBall = 0;     //coordinates of where the mouse is pressed inside second ball
         private int yInsideBall = 0;     //is pressed inside second ball
         private int x3InsideBall = 0;     //coordinates of where the mouse is pressed inside second ball
         private int y3InsideBall = 0;     //is pressed inside second ball
    /** true means mouse was pressed in ball and still in panel.*/
    private boolean _canDrag  = false;
         private boolean _canDrag2  = false;
         private boolean _canDrag3  = false;
         /** Constructor sets size, colors, and adds mouse listeners.*/
    public DragBallPanel()
              setPreferredSize(new Dimension(400, 400));
    setBackground(Color.ORANGE);
    setForeground(Color.BLUE);
    //--- Add the mouse listeners.
    this.addMouseListener(this);
    this.addMouseMotionListener(this);
    }//endconstructor
         /** Ball is drawn at the last recorded mouse listener coordinates. */
    public void paintComponent(Graphics g)
    super.paintComponent(g); // Required for background.
    g.fillOval(_ballX, ballY, BALLDIAMETER, BALL_DIAMETER);
              g.setColor(Color.RED);
              g.fillOval(x2, y2, BALL_DIAMETER2, BALL_DIAMETER2);
              g.setColor(Color.BLACK);
              g.fillOval(x3, y3, BALL_DIAMETER2, BALL_DIAMETER2);
         }//end paintComponent
         public void mousePressed(MouseEvent e)
    int x = e.getX(); // Save the x coord of the click
    int y = e.getY(); // Save the y coord of the click
    if (x >= ballX && x <= (ballX + BALL_DIAMETER)
    && y >= ballY && y <= (ballY + BALL_DIAMETER))
    _canDrag = true;
    dragFromX = x - ballX; // how far from left
    dragFromY = y - ballY; // how far from top
              else
    _canDrag = false;
              //clicked on 2nd ball
              if(x >= x2 && x <= (x2 + BALL_DIAMETER2)
                        && y >= y2 && y <= (y2 + BALL_DIAMETER2) )
                   _canDrag2  = true;
                   xInsideBall = x - x2;
                   yInsideBall = y - y2;
              else
    _canDrag2 = false;
              if(x >= x3 && x <= (x3 + BALL_DIAMETER2)
                        && y >= y3 && y <= (y3 + BALL_DIAMETER2) )
                   _canDrag3  = true;
                   x3InsideBall = x - x3;
                   y3InsideBall = y - y3;
              else
    _canDrag3 = false;
         }//end mousePressed
         public void mouseDragged(MouseEvent e)
    // True only if button was pressed inside ball.
    //--- Ball pos from mouse and original click displacement
              if (_canDrag)
    ballX = e.getX() - dragFromX;
    ballY = e.getY() - dragFromY;
    //--- Don't move the ball off the screen sides
    ballX = Math.max(ballX, 0);
    ballX = Math.min(ballX, getWidth() - BALL_DIAMETER);
    //--- Don't move the ball off top or bottom
    ballY = Math.max(ballY, 0);
    ballY = Math.min(ballY, getHeight() - BALL_DIAMETER);
    this.repaint(); // Repaint because position changed.
              if (_canDrag2)
                   x2 = e.getX() - xInsideBall;
                   y2 = e.getY() - yInsideBall;
                   x2 = Math.max(x2, 0);
                   x2 = Math.min(x2, getWidth() - BALL_DIAMETER2);
                   y2 = Math.max(y2, 0);
                   y2 = Math.min(y2, getHeight() - BALL_DIAMETER2);
                   this.repaint(); // Repaint because position changed.
              if (_canDrag3)
                   x3 = e.getX() - x3InsideBall;
                   y3 = e.getY() - y3InsideBall;
                   x3 = Math.max(x3, 0);
                   x3 = Math.min(x3, getWidth() - BALL_DIAMETER2);
                   y3 = Math.max(y3, 0);
                   y3 = Math.min(y3, getHeight() - BALL_DIAMETER2);
                   this.repaint(); // Repaint because position changed.
    }//end mouseDragged
    public void keyPressed(KeyEvent ke)
         //int x = e.getX(); // Save the x coord of the click
    //int y = e.getY(); // Save the y coord of the click
              int dx = 10;
              switch (ke.getKeyCode())
              case KeyEvent.VK_LEFT: // move x coordinate left
              _ballX -= dx;
              ballX = Math.max(ballX, 0);
              break;
              case KeyEvent.VK_RIGHT: // move x coordinate right
                   _ballX += dx;
              ballX = Math.min(ballX, getWidth() - BALL_DIAMETER);
              this.repaint();
    public void mouseMoved (MouseEvent e) {} // ignore these events
    public void mouseEntered (MouseEvent e) {} // ignore these events
    public void mouseClicked (MouseEvent e) {} // ignore these events
    public void mouseReleased(MouseEvent e) {} // ignore these events
    public void mouseExited (MouseEvent e) {}     // ignore these events
         public void keyReleased (KeyEvent ke) {} // ignore this junk
         public void keyTyped     (KeyEvent ke) {} // ignore this junk
    }//endclass DragBallPanel

    A couple of notes:
    - That code did not add the keyListener to anything.
    - At the moment (in the altered code below), only the blue circle moves, and only left/right. It is left as an exercise to the OP to 'take it from there'.
    - It only took four more lines of code to turn that code into an SSCCE*, which will generally get more help.
    - Please use code indentation, and the code formatting delimiters, when posting code. It makes code a lot easier to read and understand.
    * The SSCCE is described at..
    <http://www.physci.org/codes/sscce.html>
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DragBallPanel extends JPanel
      implements MouseListener, MouseMotionListener, KeyListener
      private static final int BALL_DIAMETER = 50; // Diameter of ball
      private static final int BALL_DIAMETER2 = 50;
      //--- instance variables
      /** Ball coords. Changed by mouse listeners. Used by paintComponent. */
      private int _ballX = 50; // x coord - set from drag
      private int _ballY = 50; // y coord - set from drag
      private int x2 = 200; // starting x coord for 2nd ball
      private int y2 = 200; //starting y coord for 2nd ball
      private int x3 = 75;
      private int y3 = 150;
      /** Position in ball of mouse press to make dragging look better. */
      private int _dragFromX = 0; // pressed this far inside ball's
      private int _dragFromY = 0; // bounding box.
      private int xInsideBall = 0; //coordinates of where the mouse is pressed inside second ball
      private int yInsideBall = 0; //is pressed inside second ball
      private int x3InsideBall = 0; //coordinates of where the mouse is pressed inside second ball
      private int y3InsideBall = 0; //is pressed inside second ball
      /** true means mouse was pressed in ball and still in panel.*/
      private boolean _canDrag = false;
      private boolean _canDrag2 = false;
      private boolean _canDrag3 = false;
      /** Constructor sets size, colors, and adds mouse listeners.*/
      public DragBallPanel()
        setPreferredSize(new Dimension(400, 400));
        setBackground(Color.ORANGE);
        setForeground(Color.BLUE);
        //--- Add the mouse listeners.
        this.addMouseListener(this);
        this.addMouseMotionListener(this);
        // add the keylistener!
        this.addKeyListener(this);
        // make sure the panel is focusable
        setFocusable(true);
      }//endconstructor
      /** Ball is drawn at the last recorded mouse listener coordinates. */
      public void paintComponent(Graphics g)
        super.paintComponent(g); // Required for background.
        g.fillOval(_ballX, _ballY, BALL_DIAMETER, BALL_DIAMETER);
        g.setColor(Color.RED);
        g.fillOval(x2, y2, BALL_DIAMETER2, BALL_DIAMETER2);
        g.setColor(Color.BLACK);
        g.fillOval(x3, y3, BALL_DIAMETER2, BALL_DIAMETER2);
      }//end paintComponent
      public void mousePressed(MouseEvent e)
        int x = e.getX(); // Save the x coord of the click
        int y = e.getY(); // Save the y coord of the click
        if (x >= _ballX && x <= (_ballX + BALL_DIAMETER)
        && y >= _ballY && y <= (_ballY + BALL_DIAMETER))
          _canDrag = true;
          _dragFromX = x - _ballX; // how far from left
          _dragFromY = y - _ballY; // how far from top
        else
          _canDrag = false;
        //clicked on 2nd ball
        if(x >= x2 && x <= (x2 + BALL_DIAMETER2)
          && y >= y2 && y <= (y2 + BALL_DIAMETER2) )
          _canDrag2 = true;
          xInsideBall = x - x2;
          yInsideBall = y - y2;
        else
          _canDrag2 = false;
        if(x >= x3 && x <= (x3 + BALL_DIAMETER2)
          && y >= y3 && y <= (y3 + BALL_DIAMETER2) )
          _canDrag3 = true;
          x3InsideBall = x - x3;
          y3InsideBall = y - y3;
        else
          _canDrag3 = false;
      }//end mousePressed
      public void mouseDragged(MouseEvent e)
        // True only if button was pressed inside ball.
        //--- Ball pos from mouse and original click displacement
        if (_canDrag)
          _ballX = e.getX() - _dragFromX;
          _ballY = e.getY() - _dragFromY;
          //--- Don't move the ball off the screen sides
          _ballX = Math.max(_ballX, 0);
          _ballX = Math.min(_ballX, getWidth() - BALL_DIAMETER);
          //--- Don't move the ball off top or bottom
          _ballY = Math.max(_ballY, 0);
          _ballY = Math.min(_ballY, getHeight() - BALL_DIAMETER);
          this.repaint(); // Repaint because position changed.
        if (_canDrag2)
          x2 = e.getX() - xInsideBall;
          y2 = e.getY() - yInsideBall;
          x2 = Math.max(x2, 0);
          x2 = Math.min(x2, getWidth() - BALL_DIAMETER2);
          y2 = Math.max(y2, 0);
          y2 = Math.min(y2, getHeight() - BALL_DIAMETER2);
          this.repaint(); // Repaint because position changed.
        if (_canDrag3)
          x3 = e.getX() - x3InsideBall;
          y3 = e.getY() - y3InsideBall;
          x3 = Math.max(x3, 0);
          x3 = Math.min(x3, getWidth() - BALL_DIAMETER2);
          y3 = Math.max(y3, 0);
          y3 = Math.min(y3, getHeight() - BALL_DIAMETER2);
          this.repaint(); // Repaint because position changed.
      }//end mouseDragged
      public void keyPressed(KeyEvent ke)
        System.out.println("key PRESSED");
        //int x = e.getX(); // Save the x coord of the click
        //int y = e.getY(); // Save the y coord of the click
        int dx = 10;
        switch (ke.getKeyCode())
          case KeyEvent.VK_LEFT: // move x coordinate left
            _ballX -= dx;
            _ballX = Math.max(_ballX, 0);
            break;
          case KeyEvent.VK_RIGHT: // move x coordinate right
            _ballX += dx;
            _ballX = Math.min(_ballX, getWidth() - BALL_DIAMETER);
        this.repaint();
      public void mouseMoved (MouseEvent e) {} // ignore these events
      public void mouseEntered (MouseEvent e) {} // ignore these events
      public void mouseClicked (MouseEvent e) {} // ignore these events
      public void mouseReleased(MouseEvent e) {} // ignore these events
      public void mouseExited (MouseEvent e) {} // ignore these events
      public void keyReleased (KeyEvent ke) {} // ignore this junk
      public void keyTyped (KeyEvent ke) {} // ignore this junk
      /** Add a main(), to make this an SSCCE. */
      public static void main(String[] args) {
        DragBallPanel dbp = new DragBallPanel();
        JOptionPane.showMessageDialog(null, dbp);
    }//endclass DragBallPanel

Maybe you are looking for

  • Supplier Directory not updated with Released status after the trasnfer

    Hello Experts, I need your help to resolve an issue. We are implementing SRM 5.0 with ROS Client and EBP Client in place to manage Supplier Self REgistration and EBP. When I trasnfer an accepted Supplier from ROS Client to EBP Client via OPI to creat

  • IPod Clas. 80GB - What kind of dock to connect to home stereo (Audio only)

    Hi Everyone, I've been reading all sorts of threads about problems people have been having with the iPod classic (80GB) and dock compatibility. Do you have any recommendations for docks that will actually work ($50-$100 range)? I'm not that technolog

  • Simple sort question - Numbers '09

    Have a table with a few colums. One is a column of dates and the other of categories. Wish to sort the entire table in priority order, first by category, then by date. Easy to do in Excel. Am sure Numbers has a way to do this, but can't find it.

  • Problem meet when call exe in java.

    hi all, in my java project, i call an external exe . now the problem is that sometimes the exe is not fully finished. How could i confirm that the exe is finished before i start to use the output of this exe. i use following code to call the external

  • SX_OBJECT_CONVERT_RAW_SCR

    hi, I am working on  this function module i.e SX_OBJECT_CONVERT_RAW_SCR in ECC 6.0 in Z function group. but this function module,doesn't exist in Ecc  6.0 however same exist in4.6c Is there any repalcement for the function module SX_OBJECT_CONVERT_RA