'Delete' KeyListener

Hi,
I have this function to add the 'delete key pressed' event.
But, the problem is that I have about 30 text input fields
and when I press the delete key to delete a character in one of
these input fields it triggers this function.
So, What I need is that somehow disable the this delete key
event when pressed inside of a text input field.
Thanks for your help.
function deleteKeyFunction():Void
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.DELETEKEY) || Key.isDown(Key.BACKSPACE))
_root.deleteKeyPress();
Key.addListener(keyListener);
}

Replace your fifth line of code with the following:
if ((Key.isDown(Key.DELETEKEY) || Key.isDown(Key.BACKSPACE))
&& eval(Selection.getFocus()).type <> "input")
This looks at the current selection - Selection.getFocus() -
and checks that it isn't an input text field.

Similar Messages

  • Key.isDown / getAscii() problems

    I'm having some trouble detecting keypresses.
    Woking with the arrow keys works fine, but using getAscii() is having problems.
    I tried using:
    if (getAscii(100)) {//do stuff;};
    but the issue is that once you press a key, getAscii() keeps returning the value of the last key pessed even after you stop pessing it.
    I tied using a keyDown listener, instead of onEnteFame and couldn't get it to work at all.
    I tried searching these foums, but some of the solutions had all the code deleted... odd.
    How do I add the ability to add key detection for the other keyboard keys to this code?
    xspeed = 0;
    yspeed = 0;
    this.onEnterFrame = function() {
         if (Key.isDown(Key.LEFT)) {
             xspeed += -3;
         if (Key.isDown(Key.RIGHT)) {
             xspeed += 3;
         if (Key.isDown(Key.UP)) {
             yspeed += -3;
         if (Key.isDown(Key.DOWN)) {
             yspeed += 3;
         xspeed *= .8;
         yspeed *= .8;
         if (Math.abs(xspeed) < 1) {xspeed = 0;};
         if (Math.abs(yspeed) < 1) {yspeed = 0;};
         if (xspeed <> 0 or yspeed <> 0) {
             _root.Map._x += xspeed;
             _root.Map._y += yspeed;
    (The code has a few exta lines to make the accelleration nice and smooth.)

    try this:
    //////////********KEY LISTENER*************************
    delete keyListener;
    Key.removeListener(keyListener);
    keyListener = new Object();
    keyListener.onKeyDown = function() {
    code.Key.getAscii();
    trace(Key.getAscii());
    if (Key.getAscii() == 97) {
      trace("A hit");
    ///*************spacebar *********************
    if (Key.isDown(32)) {
      trace("space bar pressed");
    ////*********CONTROL J***********************         
    if (Key.isDown(Key.CONTROL) && Key.getCode() == 74) {
      trace("CONTROL J");
    ////********* p ***********************         
    if (Key.isDown(112)) {
      trace("p");
    ////********* q ***********************         
    if (Key.isDown(113)) {
      trace("g");
    ////*********F1***********************  
    if (Key.getCode() == 112) {
      trace("F1");
    Key.addListener(keyListener);
    Important:
    Always remember to remove your listener before calling on it again.Most of the time I place it on a frame the user can NOT return to, because it will keep adding listeners and you can easly build up hundreds of them. So remeber to remove it before calling it again...just like the above code does already.

  • JTable Deletions

    I am using JTable to display a series of simple text strings. Every cell contains the same kind of data; it isn't querying a database or anything like that. The user must be able to delete these cells quickly, so the design of the application is such that the delete key can be pressed several times in succession to delete successive elements. I am using the standard construct to accomplish this:
    if (keyEvent.getKeyCode() == java.awt.event.KeyEvent.VK_DELETE) {...}
    This is a 2 year old app that has run fine in production under JDK 1.1.8. However, when moving to 1.3.1, pressing the delete key causes the currently selected element only to be deleted. While the table updates correctly and the next element is highlighted, nothing happens upon subsequent presses of DELETE. If a cursor key or the mouse is used to select an element -- even the currently highlighted one -- then that element may be deleted, but the cycle repeats itself.
    After combing the JDK docs, Sun's tutorials, and the Forums, I am at a loss. I've tried using editCellAt(), setEditingColumn/Row(), clearSelection(), & changeSelection() after firing the deletion event. Any ideas?

    OK, here's a complete example. Why don't you see what you can do with it?
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    public class TableTest implements KeyListener, TableModel
        public TableTest()
            tableData.add(new String[] { "a", "aa", "aaa", "aaaa" });
            tableData.add(new String[] { "b", "bb", "bbb", "bbbb" });
            tableData.add(new String[] { "c", "cc", "ccc", "cccc" });
            tableData.add(new String[] { "d", "dd", "ddd", "dddd" });
            table = new JTable(this);
            table.addKeyListener(this);
        String columnHeader[] = { " ", "Name", "Type", "Node" };
        JTable table;
        Vector tableData = new Vector();
        Vector tableModelListeners = new Vector();
        // TableModel methods.
        public void addTableModelListener(TableModelListener listener)
            synchronized (tableModelListeners)
                if (!tableModelListeners.contains(listener))
                    tableModelListeners.add(listener);
        public void removeTableModelListener(TableModelListener listener)
            synchronized (tableModelListeners)
                tableModelListeners.remove(listener);
        public Class getColumnClass(int column) { return ((Object[]) tableData.elementAt(0))[column].getClass(); }
        public String getColumnName(int column) { return columnHeader[column]; }
        public int getColumnCount() { return columnHeader.length; }
        public int getRowCount() { return tableData.size(); }
        public Object getValueAt(int r, int c) { return ((Object[]) tableData.elementAt(r))[c]; }
        public void setValueAt(Object value, int r, int c) { ((Object[]) tableData.elementAt(r))[c] = value; }
        public boolean isCellEditable(int r, int c) { return false; }
        private void tableChanged()
            TableModelEvent event = new TableModelEvent(this);
            synchronized (tableModelListeners)
                for (int count = tableModelListeners.size(), i = 0; i < count; i++)
                    ((TableModelListener) tableModelListeners.elementAt(i)).tableChanged(event);
        // KeyListener methods.
        public void keyPressed(KeyEvent ev) { }
        public void keyTyped(KeyEvent ev) { }
        public void keyReleased(KeyEvent ev)
            if (ev.getKeyCode() == KeyEvent.VK_DELETE)
                int row = table.getSelectedRow();
                if (row != -1)
                    tableData.remove(row);
                    tableChanged();
                    if (row < table.getRowCount()) table.setRowSelectionInterval(row, row);
        public static void main(String[] arg)
            TableTest test = new TableTest();
            JFrame frame = new JFrame("Table Test");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(400, 300);
            frame.setLocation(200, 200);
            frame.getContentPane().add(new JScrollPane(test.table));
            frame.show();

  • JTable keylistener

    Hello.
    I would like that the user can delete a row of my table by pressing the 'delete' key. In fact, I add a keylistener to my table and and I can catch all key event except the special keys like 'delete'
    Can you help me ?

    Are you using [Key Bindings|http://www.camick.com/java/blog.html?name=key-bindings]?
    For more help create a [SSCCE (Short, Self Contained, Compilable and Executable, Example Program)|http://sscce.org], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Output stream with a keylistener

    Hello,
    I have a program that basically runs .class and .jar console based programs, using JFileChooser to open them and such. I have managed to capture the System.out and System.err streams from running processes and using p.getInputStream() and p.getErrorStream(), just appending a JTextArea with each character in the stream. Now I'm trying to get the System.in stream connected.
    I have a keylistener attached to my JFrame, like this
    String line;
    frame.addKeyListener(new KeyListener() {
         @Override
         public void keyPressed(KeyEvent e) {}
         @Override
         public void keyReleased(KeyEvent e) {
              Character key = e.getKeyChar();
              //Delete the last character in both the JTextArea and the current line
              if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
                   if (output.getText().charAt(output.getText().length()-1) != '\n') {
                        String text = output.getText().substring(0, output.getText().length()-1);
                        output.setText(text);
                        line = line.substring(0, line.length()-1);
                   //Write line to OutputStream and put a new line in the JTextArea                              
              } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                       //writeToOutput("\n-------\nLine reads: " + line + "\n--------\n");
                   writeToOutput("\n");
                   line = "";
              //Add any other characters to the line and show them in the JTextArea
              } else if (e.getKeyCode() != KeyEvent.VK_SHIFT) {
                   writeToOutput(key + "");
                   line = line + key;
         @Override
         public void keyTyped(KeyEvent e) {}                         
    });What happens is that the user types a line of characters, then presses enter. What I want is for when enter is pressed that the line is written to some sort of OutputStream in such a way that I can use it to provide input to a process with p.getOutputStream(OutputStream);
    Which OutputStream do I have to use and how? It's all a bit confusing :S
    Thanks,
    Jack
    Edited by: jackCharlez on Nov 23, 2009 1:25 PM
    Edited by: jackCharlez on Nov 23, 2009 1:33 PM

    Solved, using
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
    Out.write in my keylistener and out.newline(); out.flush(); when the user presses enter.
    ^ For anyone googling this problem :P

  • KeyListener efficiency (runtime question)

    I have a JTextArea in which the user can type. I basically wish to record the most recent text that the user has typed ( this is everytime they type a character, delete, etc...). From what I know so far, it is possible to do this two ways:
    1. Use a KeyListener (I am assuming an interface like this exists), and whenever it picks up a key that would alter the text (all letters, punctuation, backspace, etc...) it uses the JTextArea's getText() method to get the text.
    2. Have a thread which has the String returned by JTextArea's getText() saved. Every n milliseconds (a good number would be 100, perhaps?) , the thread would invoke the JTextArea's getText(), compare it to the String previously saved, , check for a difference, and then if there is a difference, save the new text to the String.
    Which one is more runtime-efficient?

    I have a JTextArea in which the user can type. I
    basically wish to record the most recent text that
    the user has typedWouldn't you also want to know if the user pasted in some code from the clipboard?
    If you want to keep track of all changes to the JTextArea no matter what caused them, then get its Document and attach a DocumentListener to it.

  • Delete File From Mounted Volume

    Hey,
    I am trying to delete the "Calendar Cache" files on both my laptop PowerBook G4 and the Mac Pro Quad that I sync my calendars with. I am using ChronoSync and the individual calendars sync fine, but there is a little house keeping needed with the cache file. They need to be deleted on both systems in order to "refresh" the views of the calendars.
    So after the sync of calendars, I have the software initiating an AppleScript that deletes both. Here's the script:
    +(* PowerBook Files / delete cache file *)+
    +(* Please note that both systems have the same username. This may be arise a conflict *)+
    +tell application "Finder"+
    + activate+
    + tell application "Finder" to delete file "Calendar Cache" of folder "Calendars" of folder "Library" of disk "useranthony"+
    +end tell+
    +(* Mac Pro Quad/ delete cache file *)+
    +tell application "Finder"+
    + mount volume "afp://10.10.10.1/anthonyabraira"+
    + tell application "Finder" to delete file "Calendar Cache" of folder "Calendars" of folder "Library" of disk "/volumes/useranthony"+
    +end tell+
    I am having trouble addressing a deletion on the networked Mac Pro Quad.

    why send it to the trash — just delete it...
    (* PowerBook Files / delete cache file )
    try
            do shell script "rm -rf /Library/Calendars/Calendar\\ Cache"
    end try
    you may need a delay for the Mac Pro Quad to mount
    ( Mac Pro Quad/ delete cache file *)
    --the mount and then the delay
    delay 4
    try
            do shell script "rm -rf /THE-CORRECT/PATH-HERE/Library/Calendars/Calendar\\ Cache"
    end try
    Tom

  • How to delete the members in one dimension use the maxl script

    i have question that i want to delete the members in one dimension useing the maxl script, but i do not know how to do it. can the maxl delete the members in one dimension? if can, please provide an sample script, thank you so mcuh.

    MaxL does not have commands to alter an outline directly, except the reset command which can delete all dimensions but not members selectively. The best you could do would be to run a rules file (import dimensions) using a file that contains the members you want to keepload rule for the dimension. As typical the warning is to test this first before you do it on a production database

  • Error while deleting a mapping

    Hi all,
    I am getting the following error while deleting a mapping. My client version is 10.2.0.4.36
    API5072: Internal Error: Null message for exception. Please contact Oracle Support with the stack trace and details on how to reproduce it.
    oracle.wh.util.Assert: API5072: Internal Error: Null message for exception. Please contact Oracle Support with the stack trace and details on how to reproduce it.
         at oracle.wh.util.Assert.owbAssert(Assert.java:51)
         at oracle.wh.ui.jcommon.OutputConfigure.showMsg(OutputConfigure.java:216)
         at oracle.wh.ui.common.CommonUtils.error(CommonUtils.java:370)
         at oracle.wh.ui.common.WhDeletion.doActualDel(WhDeletion.java:512)
         at oracle.wh.ui.common.WhDeletion.deleteObject(WhDeletion.java:203)
         at oracle.wh.ui.common.WhDeletion.deleteObject(WhDeletion.java:283)
         at oracle.wh.ui.jcommon.tree.WhTree.deleteItem(WhTree.java:346)
         at oracle.wh.ui.console.commands.DeleteCmd.performAction(DeleteCmd.java:50)
         at oracle.wh.ui.console.commands.TreeMenuHandler$1.run(TreeMenuHandler.java:188)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:189)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:478)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    Thanks in advance!
    Sebastian

    These type of Internal Errors are all too common in OWB and it's difficult to diagnose the exact problem.
    I'd suggest closing the Design Centre, going back in and trying to delete it again, this will often resolve Internal errors.
    There's also an article on Metalink Doc ID: 460411.1 about errors when deleting mappings but it's specific to an ACLContainer error, so may or may not be of use.
    One of the suggestions is to connect as the Repository Owner rather than a User and try to delete the mapping.
    Cheers
    Si
    Edited by: ScoobySi on Sep 10, 2009 11:44 AM

  • Adobe cloud tries to load addon which I have deleted in Extension manager

    when Adobe Cloud starts it tries to load an application (Edge FX lite) that I have deleted in Adobe Extension Manager cc. I get the error message ' unable to install the addon EdgeFX lite  error 603. How do I stop this?
    Also in Adobe Exchange in 'My Stuff'  there are showing addons which I have removed in Adobe extension Manager cc which I would like to be removed from this listing as I will never use them, but if I right click to uninstall I fail to get rid of them.

    Apologies, without making the assumption that you are signed in
    1) Go to https://creative.adobe.com/addons/
    2) In the top right hand corner select sign in and enter your Adobe ID and password
    3) Once logged in, on the center of the screen at the left hand side, select the link 'All your purchases and shared items'
    4) You will then be taken to a page that is the equivalent of your My Stuff panel.
    5) You can then install individual add-ons/extensions.
    Kind regards,
    Lea

  • IPhone voice memos can't be deleted

    I have unchecked voice memos and eleted others from my itunes library, but they still show in Voice Memos on the iphone (when viewed from itunes. How do I get rid of them from the iphone. I think this is why I have 4GB of OTHER cluttering my iphone memory

    Thanks, selecting Manually Manage allowed me to delete the errant voice memo files. Curiously, it did not delete within the general Music folder so had to dlete from there as well. I think they are gone, but saw no reduction in space used. Have to look somewhere else for that.

  • IPhone Deletes Exchange Emails To Wrong Folder

    Hello all!
    I have a Microsoft Exchange mail account setup on my iPhone 4 (iOS 6.1) which works wonderfully, short of one aspect:  Emails deleted from my phone do not go to the accounts standard 'Trash' folder, but to a different 'Deleted' folder.  I can see no way to change this setting.  Any ideas?

    Thanks Templeton.  This is the only definitive answer I've found anywhere.  Turns out my iPhone was correct and my other email clients are sending to the wrong folder!

  • When I sync my iPod to my MacBook through iTunes new events do not show up and old events are not deleted. I am using Snow Leopard  and not iSync.

    I am using Snow Leopard on a MacBook. I have an iPod touch 3G. I do not use iSync it Mobile Me. When I sync my iPod through iTunes new events on my iPod do not show up on my Mac and old events do not delete. I have read help instructions that include deleting the data on the iPod. The iPod has the correct data and the Mac does not so I have not followed those instructions. I need help as the only reason I bought the Mac was to be able to sync, back up, view and print my calendar. Currently it is useless. If only Apple could have learned from the elegance of the Palm software.

    Start here:
    iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows

  • How do you delete duplicate songs from your iPhone that do not show up in your iTunes library?

    everytime i purchase songs on itunes and sync them to my iphone 4, the songs downloads twice. one as the actual song, and the second one doesnt do anything. when you click on it, it just skips to the next song and doesnt play anything. also this second song has this cirlce dot thing next to it when i am scrolling through my songs in my music...so how do i get rid of this second download? its really annoying to have and it wont let me delete it off my phone. alsoooo since it doesnt show up in my itunes library, i cant delte it off there either! HELP PLEASE

    On the springboard, locate the app you want to delete. For this example, I’ll use WeatherBug.
    Tap and hold down the icon of the application you want to delete. After a few seconds your screen will start to “wiggle” and an X will appear next to each of the apps you’ve installed via the App Store.
    Tap the X next to the icon of the app you want to remove. When prompted, selectDelete.
    And now it’s gone.
    If the application is listed in your iTunes Applications as well, you’ll want to remove it from there – or else it will re-install the next time you sync. Alternately you can keep the app in your iTunes Applications, and set iTunes not to sync all applications, just the ones you want to keep. See the Applications tab of your device the next time it’s connected in iTunes for syncing options.
    http://www.simplehelp.net/2008/07/12/how-to-delete-apps-from-your-ipod-touch-or- iphone/

  • Downloaded ios7 to my iphone 4 and now I have songs that I cannot delete and they do not show up on itunes either

    Daughter upgraded to ios 7 and now she has like 4 songs that are not age appropriate on her iphone- I went into itunes and they dont show up...they are like hidden or something- and I cannot delete them from the phone...does anyone know why the upgrade did this and how I can get these songs off her phone- one of them is not even on my phone so I dont understand how in the world it popped onto hers! thanks!

    Hello DavoDavo81,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    iTunes Match on iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT5637
    Deleting songs downloaded to your device
    You can delete a song or album from your iPhone, iPad, or iPod touch at any time. Don't worry; it'll still be in the cloud.
    Tap the Music app.
    Tap More > Songs at the bottom.
    Scroll or search for the song you would like to delete from your device.
    Swipe right to left on the song, and then tap Delete.
    Note: You must be in Artists, Songs, or Albums view to delete songs from your device. Deleting from a playlist won't remove a song from your iOS device.
    iTunes Store: How to delete songs from iCloud
    http://support.apple.com/kb/ht4915
    Best of luck,
    Mario

Maybe you are looking for