touch-event

How to show a customized Popup window near the touch location, like what we have when we use ContextMenu?

此生再无相见时 提交于 2019-11-30 09:40:17
问题 Background Seeing that it's not officially possible to have a context menu which has a customized view or even icons for its rows (here), I decided to create my own solution (of custom view that acts like it). The problem When using a context menu on a RecyclerView, the touch position matters, so if you long touch an item, the context menu will try to appear near the touch location (sample taken from here), and without me giving this information (meaning via OnClickListener or

Touch events on MKMapView's overlays

一曲冷凌霜 提交于 2019-11-30 09:09:21
In the app I'm currently designing I have a MKMapView with overlays on it (customized MKPolylines btw) and I would like to be able to detect touch events on these overlays and assign a specific action to each overlay. Could any one help me on this one ? Thanks ! Benja Jano This can be solved combining How to intercept touches events on a MKMapView or UIWebView objects? and How to determine if an annotation is inside of MKPolygonView (iOS) . Add this in viewWillAppear: WildcardGestureRecognizer * tapInterceptor = [[WildcardGestureRecognizer alloc] init]; tapInterceptor.touchesBeganCallback = ^

Prevent default Press but not default Drag in iOS MobileSafari?

南笙酒味 提交于 2019-11-30 03:38:57
Context : Web app on MobileSafari/iPad, both full-screen and embedded in iframe Goal : Technique that provides custom event handlers for Press and Tap but not Pinch (zoom) or Drag (scroll/pan). We want to provide custom behavior for Press, but to let Safari handle Scroll/Pan/Zoom still. Problem : The two goals seem to be mutually exclusive. To prevent the default behavior for a Press gesture, event.preventDefault must be called in immediate response to ontouchstart . However, to let the default behavior proceed on a Drag, we must not call event.preventDefault on the initial ontouchstart. Once

Is there a touch method for UILabel?

主宰稳场 提交于 2019-11-30 03:15:53
I'd like to do an action if someone touches a predeclared UILabel , something like: if (label is touched) { my actions; } Is there a method/way to do that? You could use a gesture recognizer: - (void)someSetupMethod { // ... label.userInteractionEnabled = YES; UITapGestureRecognizer *tapGesture = \ [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapLabelWithGesture:)]; [label addGestureRecognizer:tapGesture]; [tapGesture release]; } - (void)didTapLabelWithGesture:(UITapGestureRecognizer *)tapGesture { // ... } By default, UILabel isn't configured to accept touch input.

jQuery (Swipe vs. Touch) pageX and pageY keep returning 0

﹥>﹥吖頭↗ 提交于 2019-11-30 02:23:22
I'm playing with touchstart and touchend events on my iPhone. I built a sample page that has div that if you touch it and scroll the page, it should return the y coordinates of the start and end positions. link: http://jsbin.com/ibemom/2 the jQuery: var touchStartPos; $('.theDiv') .bind('touchstart', function(e){ touchStartPos = e.pageY; }) .bind('touchend', function(e){ alert(touchStartPos + ' | ' + e.pageY) }) When I load that page on my iPhone, however, the alert keeps reporting both values as zero. Anyone see anything wrong with what I have? UPDATE: I stumbled across this bit of code in

Can't get coordinates of touchevents in Javascript on Android devices

拥有回忆 提交于 2019-11-30 01:28:34
I'm testing the HTML5 canvas and using Javascript to draw for touch enabled devices. While I have it working in iOS devices I cannot get it to work on Android. I have narrowed it down to event.pageX not returning the coordinates, but instead either returning 0, or undefined (based on the Browser). I've tested it on my phone running Cyanogen 7.1 in Opera Mobile and Dolphin browser, and also on a Galaxy Tab 10.1 (Android 3.1) running the standard browser. I've modified the code to show an alert on a touchstart event displaying the event.pageX, event.layerX and event.clientX coordinates (I'm

Should superview's gesture cancel subview's gesture in iOS 7?

房东的猫 提交于 2019-11-29 18:43:12
问题 For several years now I've operated under the assumption that if a superview and its subview both have gesture recognizers, the subview would receive the touches first and cancel out the superview's gesture. Until iOS 7 this assumption never failed me, allowing me to add gestures to subviews confident the superview's gestures wouldn't interfere. But in iOS 7, the superview will randomly receive the touches first and cancel out the subview's gestures. This happens somewhat rarely, which made

Android firing onTouch event for multiple ImageViews

时光毁灭记忆、已成空白 提交于 2019-11-29 12:37:00
I have several ImageViews, and I want the onTouch event to fire for each of them when I drag my finger across multiple images. At present the onTouch event is only firing on the first ImageView (or actually on multiple ImageViews but only when multitouching the screen). Pseudo code: for(int i=0;i<5;i++){ ImageView img=new ImageView(this); LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(width,height); img.setImageResource(R.drawable.cell); img.setOnTouchListener(this); mainLayout.addView(img,layoutParams); } ... public boolean onTouch (View v, MotionEvent event){ Log.d("MY

Receiving Touch Events from a Service (Solution?)

北城余情 提交于 2019-11-29 12:35:10
So, earlier I posted a question about receiving touch events from a service (apparently no one knows the answer). After trying to figure it out myself for hours, I gave up and decided to email a developer known as RubberBigPepper. I asked him how he did it in his app Volume control and he promptly responded " TYPE_SYSTEM_ALERT window ". What does this mean, and how can it be implemented in code? EDIT: I used the following method: getWindow().addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); and the window failed to receive touch events. I emailed him about this as well and he says: "Use

Android : Get view only on which touch was released

浪尽此生 提交于 2019-11-29 12:17:57
I am in a tricky situation, hope you can help me with it. I have few views (TextViews), horizontally placed one after another in a linear layout. When I press on textview1, drag my finger to any other textview and release touch, I want to be able to get the view(textview) on which the finger was lifted. I went over the TouchListener api, it says that every event starts with a ACTION_DOWN event action. Since other textviews won't fire that event, how can I get the reference to the textViews on which I lifted my finger? I tried it even, and the action_up would fire only on the textView that