Advertisement
Guest User

Untitled

a guest
May 27th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. private class _CommandView extends EditText {
  2.  
  3. //HERE posting events works only with **TextBufferWindow.this**!!
  4.  
  5. public void sendReturnSignal() { //unused
  6. CharInputEvent ev = new CharInputEvent(TextBufferWindow.this, KeyEvent.KEYCODE_ENTER);
  7. mGlk.postEvent(ev);
  8. }
  9.  
  10. public boolean mCharInputEnabled;
  11. public boolean mLineInputEnabled;
  12. private TextWatcher mWatcher = new TextWatcher() {
  13. public void afterTextChanged(Editable s) {
  14. }
  15.  
  16. public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
  17. }
  18.  
  19. public void onTextChanged(CharSequence s, int start, int before, int count) {
  20. int char_inp = 0;
  21.  
  22. if (mCharInputEnabled) {
  23. //skipped; handles chars
  24. } else {
  25. if (char_inp > 0) {
  26. disableInput();
  27.  
  28.  
  29. SpannableStringBuilder sb = new SpannableStringBuilder();
  30.  
  31. if (mGlk.getNorth() == true) {
  32. //mGlk handles Events and all sub-views
  33. sb.append("north" + "n");
  34. mGlk.releaseNorth(); //free flag
  35. } else
  36. sb.append(getText().toString().replace("n","")+"n");
  37.  
  38. Object sp = stylehints.getSpan(mContext, Glk.STYLE_INPUT, false);
  39. if (sb.length() > 0)
  40. sb.setSpan(sp, 0, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
  41.  
  42. lineInputAccepted(sb);
  43. }
  44. }
  45. }
  46. };
  47.  
  48. public _CommandView(Context context) {
  49. super(context, null, R.attr.textBufferWindowEditStyle);
  50.  
  51. //some sets()...
  52.  
  53. addTextChangedListener(mWatcher); //here is added when first created
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement