Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Override backspace key android

Options
  • 21-01-2013 1:09pm
    #1
    Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭


    I am connecting to a terminal emulator using a library in android, this connects to a serial device (a switch) and shows me sent/received data. I send data over the connection via a text box below the terminal or by typing in the terminal itself and hitting enter on the keyboard in both cases. It will only ever be a soft keyboard that is used. If I send an incorrect string I am in an unrecoverable state due to not having a delete key implementation. Backspace in my editTExt works fine, I just want it to work when the terminal is highlighted and I am writing in that.

    At the moment if I press delete a little odd box character comes up and nothing else happens, I get an exception in the log some times(http://i.imgur.com/wMRaLPX.png). What I want to know is how to I go about changing the delete keys functionality so that when I press it I can send a delete character like this but also retain the ability to delete characters in the edittext box etc:

    sendOverSerial("\b".getBytes("UTF-8"))
    This sends a correct back space, I just need to incorporate it.


    But the soft-keyboard doesn't seem to register key presses? i keep getting a keycode of 0 and only enter will work.

    Currently trying out http://stackoverflow.com/questions/4886858/android-edittext-deletebackspace-key-event/11377462#comment19862035_11377462 but any other suggestions would be great, as about 10 suggestions haven't worked so far. My backspace wouldn't be associated with an editText, but a terminal View. I can't even detect the delete key being pressed.


Comments

  • Registered Users Posts: 7,109 ✭✭✭witnessmenow




  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    That kinda works thanks. :)

    If the editText is selected, the terminal deletes characters over serial now, so that is a good step. However the main problem still exists that if the terminal is selected itself, weird little boxes are written to the screen instead of deleting a character. Well one is written, and if I keep pressing delete it stays at that one box, but next time I type the amount of deletes I pressed comes up as boxes. It's very odd...

    It's like it is just overridden for the edittext and not for the terminal.


    Weird little boxes in all their glory:

    6NcRE8v.png


  • Registered Users Posts: 7,109 ✭✭✭witnessmenow


    are you replacing the delete command in the dispatchKeyEvent with the "\b" ?

    Sorry I am a little confused between what the terminal is and the text box is? Is the terminal its own component?


Advertisement