touch-event

How to Highlight this pdf page using Ontouchevent in android

*爱你&永不变心* 提交于 2019-12-07 00:01:26
问题 Here I want to highlight this text using onTouchevent in android 回答1: You could use OnTouchListener to get the x and y of the event. Then drawing the screen to a bitmap and using bitmap.getPixel based on the top left display of the letter nd the size of your letters, to see if the next letter(s) next to it are also not spaces.Finally, put a yellow rectangle in between the white and the black lettering or the ones you wish to have highlighted. 回答2: You have to implement the onTouchListener for

Modernizr.touch returns true on firefox browser

≡放荡痞女 提交于 2019-12-06 19:50:16
问题 I have written a peace of code to get the event based on touch and non-touch. Its working all other browsers and devices, but Firefox. Default FF return the true . var thumbsEvent, isTouch = Modernizr.touch; // detect the touch if(isTouch){ thumbsEvent = 'click';//on touch surface, click } else { thumbsEvent = 'mouseover';//on non touch surface, mouseover } Is there a way to manage this issue. Example fiddle 回答1: On behalf of Modernizr - We're really sorry about this. Modernizr.touch has been

android graphview getting touch location

坚强是说给别人听的谎言 提交于 2019-12-06 15:23:17
问题 First off I am using this library in my app http://www.jjoe64.com/p/graphview-library.html to create the graphs. I then use this code (which I found in the comments) to get the x location of the touch event. //intercepts touch events on the graphview @Override public boolean dispatchTouchEvent(MotionEvent event) { switch (event.getAction()) { //when you touch the screen case MotionEvent.ACTION_DOWN: // gets the location of the touch on the graphview float x = event.getX(event.getActionIndex()

removing the onclick delay for webapps for android

╄→гoц情女王★ 提交于 2019-12-06 13:55:40
Hi i'm building a webapp. To remove the onclick delay i found this script on http://cubiq.org/remove-onclick-delay-on-webkit-for-iphone The code is bascically- function NoClickDelay(el) { this.element = el; if( 'ontouchstart' in window ){ console.log("===================touch supported :P") this.element.addEventListener('touchstart', this.handleEvent, false); } } NoClickDelay.prototype = { handleEvent: function(e) { switch(e.type) { case 'touchstart': this.onTouchStart(e); break; case 'touchmove': this.onTouchMove(e); break; case 'touchend': this.onTouchEnd(e); break; } }, onTouchStart:

Touch intercepted after fling

怎甘沉沦 提交于 2019-12-06 11:58:39
Recently I am experiencing some issues with my scrollview. Touch events don't reach elements inside a scrollview after a fling has happened. After a fling has occurred I first need to tap the view once again, after that the normal behaviour is restored. I already tried lot's of workarounds like: Manually fire a motion event (up / down) after the fling. This works but has some serious issues, I don't have to explain why I guess since this is just the same as touching the view again but that at a certain x+y. Intercept touch events and always pass them to the underlying views. But all this is

touchend handler fires twice

早过忘川 提交于 2019-12-06 07:42:20
问题 On a webapp on iOS, I have a bunch of buttons that respond only to touchend (as a shortcut to the click delay in mobile safari). When I stick an alert in the handler, then a subsequent tap of any other button on the page fires this original handler even though they have their own handlers. Here's some sample code that illustrates the problem: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;" /> <meta name=

How to calculate the percentage of erased area of a bitmap in android?

天大地大妈咪最大 提交于 2019-12-06 04:56:13
问题 I'm new to android. I'm doing an application which can erase the bitmap on canvas using finger. Something like finger paint eraser. I want to calculate the percentage of erased area (eg. 60% has been erased from complete image). Please help me to do this.. Thanks in advance.. I tried some method. It always give me 0%. Its not working. See the bottom of the code for that method.. Customized View public class MyView extends View { private final Paint mPaint; private Bitmap mBitmap; private

Android - User paints lines with their finger

不想你离开。 提交于 2019-12-06 04:39:47
I want to build a tool on Android where the user can paint some simple objects over a picture (eg line, circle or arrow). I started trying the line part first, and indeed I could succeed on painting it. The logic is that the user taps at one point and then drags their finger, painting the line. I use a class like this (it is based on DonGru's answer here ): public class DrawView extends View { Paint paint = new Paint(); float Sx, Sy, Lx, Ly; public DrawView(Context context, float x1, float y1, float x2, float y2) { super(context); paint.setColor(Color.RED); Sx=x1; Sy=y1; Lx=x2; Ly=y2; }

Android: using MotionEvent to do drag and drop positioning of Views in a custom ViewGroup

元气小坏坏 提交于 2019-12-06 04:37:21
问题 I am having trouble positioning view elements on a custom ViewGroup that I have created, specifically in drag-and-drop situations. I am targeting Android 2.2 and up, so I can't really use the drag-and-drop API that came into existence in Android 3. My custom ViewGroup is called "NodeGrid" and it extends "RelativeLayout". Its onLayout method is overriden such that it looks like this: @Override protected void onLayout(boolean arg0, int arg1, int arg2, int arg3, int arg4) { //pxConversion is a

Android Multi Touch

荒凉一梦 提交于 2019-12-06 04:18:24
So, I am trying to check multiple screen touches with an onTouchEvent, but it still only seems to read the first touch. Can anyone help? Here is my code: public boolean onTouchEvent(MotionEvent e) { int num = e.getPointerCount(); for(int a = 0;a<num;a++) { int x = (int) e.getX(e.getPointerId(a)); int y = (int) e.getY(e.getPointerId(a)); check(x,y); } return false; } I looked over a lot of these forums, but most of the multi touch related topics were about zooming. Your code works well on my device (Nexus S, Android 2.3). It reads all touches. Here is the test code: public boolean onTouchEvent