forgot to mention that "widget" in the code is actually the TextView being touched. IIRC this code comes from ArrowKeyMovementMethod. Don't know about WebView or other components.
On Mar 11, 1:16 am, Vladimir <[email protected]> wrote: > Something along the lines of: > onTouchEvent(... MotionEvent event) { > > if (event.getAction() == MotionEvent.ACTION_UP) { > > int x = (int) event.getX(); > int y = (int) event.getY(); > > x -= widget.getTotalPaddingLeft(); > y -= widget.getTotalPaddingTop(); > > x += widget.getScrollX(); > y += widget.getScrollY(); > > Layout layout = widget.getLayout(); > int line = layout.getLineForVertical(y); > int off = layout.getOffsetForHorizontal(line, x); > ... > > or take a look at TextView/MovementMethod source. I faced a similar > task recently (EditText with clickable links) and ended up writing a > custom MovementMethod. > > On Mar 10, 9:20 am, Glen Lewis <[email protected]> wrote: > > > > > When a touch event has occurred in any control showing a block of text > > (TextView, EditText, WebView, others), how does one get the text where > > the touch occurred? > > > For example, if a TextView control contained "now is the time for all > > good men to come to the aid of their country" and the word "time" is > > touched, how can I find that out programatically? > > > I've searched the forums and the 'net to no avail and I've seen this > > question posted here a few times never with an answer. I'm hoping > > that I'm just missing something obvious... > > > Thanks! > > -Glen -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

