Skip to content

Commit

Permalink
Merge pull request #9341 from garymathews/TIMOB-25186_6_2_X
Browse files Browse the repository at this point in the history
[6_2_X][TIMOB-25186] Validate Ti.UI.Label onTouchEvent
  • Loading branch information
mukherjee2 committed Aug 23, 2017
2 parents 80f540f + f60fc70 commit 499e1d7
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,26 @@ public boolean onTouchEvent(MotionEvent event) {
y += textView.getScrollY();

Layout layout = textView.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);

ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);

if (link.length != 0) {
ClickableSpan cSpan = link[0];
if (action == MotionEvent.ACTION_UP) {
TiViewProxy proxy = getProxy();
if(proxy.hasListeners("link") && (cSpan instanceof URLSpan)) {
KrollDict evnt = new KrollDict();
evnt.put("url", ((URLSpan)cSpan).getURL());
proxy.fireEvent("link", evnt, false);
} else {
cSpan.onClick(textView);
if (layout != null) {
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);

ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);

if (link.length != 0) {
ClickableSpan cSpan = link[0];
if (action == MotionEvent.ACTION_UP) {
TiViewProxy proxy = getProxy();
if(proxy.hasListeners("link") && (cSpan instanceof URLSpan)) {
KrollDict evnt = new KrollDict();
evnt.put("url", ((URLSpan)cSpan).getURL());
proxy.fireEvent("link", evnt, false);
} else {
cSpan.onClick(textView);
}
} else if (action == MotionEvent.ACTION_DOWN) {
Selection.setSelection(buffer, buffer.getSpanStart(cSpan), buffer.getSpanEnd(cSpan));
}
} else if (action == MotionEvent.ACTION_DOWN) {
Selection.setSelection(buffer, buffer.getSpanStart(cSpan), buffer.getSpanEnd(cSpan));
}
}
}
Expand Down

0 comments on commit 499e1d7

Please sign in to comment.