コード例 #1
0
 public boolean onTouchEvent(MotionEvent event) {
   int n = getOffsetForPosition(event.getX(), event.getY());
   if (event.getAction() == MotionEvent.ACTION_UP && n >= 0) {
     String s = getText().toString().substring(0, n);
     if (soft_cursor) s = s.replace(soft_cursor_text, "").replace(" ", "");
     n = s.length();
     Rime.RimeSetCaretPos(n);
     TrimeService.getService().updateComposing();
   }
   return true;
 }
コード例 #2
0
 public void setText() {
   if (getVisibility() != View.VISIBLE) return;
   Rime.RimeComposition r = Rime.getComposition();
   String s = "";
   if (r != null) s = r.getText();
   if (soft_cursor) s = s.replace(caret, soft_cursor_text);
   setText(s, BufferType.SPANNABLE);
   int n = s.length();
   if (n > 0 && r != null) {
     SpannableString ss = (SpannableString) getText();
     int start = r.getStart();
     int end = r.getEnd();
     ss.setSpan(hilited_text_color_span, start, end, SpannableString.SPAN_INCLUSIVE_INCLUSIVE);
     ss.setSpan(hilited_back_color_span, start, end, SpannableString.SPAN_INCLUSIVE_INCLUSIVE);
     ss.setSpan(underline_span, start, end, SpannableString.SPAN_INCLUSIVE_INCLUSIVE);
   }
 }