Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class _CommandView extends EditText {
- //HERE posting events works only with **TextBufferWindow.this**!!
- public void sendReturnSignal() { //unused
- CharInputEvent ev = new CharInputEvent(TextBufferWindow.this, KeyEvent.KEYCODE_ENTER);
- mGlk.postEvent(ev);
- }
- public boolean mCharInputEnabled;
- public boolean mLineInputEnabled;
- private TextWatcher mWatcher = new TextWatcher() {
- public void afterTextChanged(Editable s) {
- }
- public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
- }
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- int char_inp = 0;
- if (mCharInputEnabled) {
- //skipped; handles chars
- } else {
- if (char_inp > 0) {
- disableInput();
- SpannableStringBuilder sb = new SpannableStringBuilder();
- if (mGlk.getNorth() == true) {
- //mGlk handles Events and all sub-views
- sb.append("north" + "n");
- mGlk.releaseNorth(); //free flag
- } else
- sb.append(getText().toString().replace("n","")+"n");
- Object sp = stylehints.getSpan(mContext, Glk.STYLE_INPUT, false);
- if (sb.length() > 0)
- sb.setSpan(sp, 0, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- lineInputAccepted(sb);
- }
- }
- }
- };
- public _CommandView(Context context) {
- super(context, null, R.attr.textBufferWindowEditStyle);
- //some sets()...
- addTextChangedListener(mWatcher); //here is added when first created
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement