OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_UI_CONTEXTUAL_SEARCH_WINDOW_GESTURE_OBSERVER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_CONTEXTUAL_SEARCH_WINDOW_GESTURE_OBSERVER_H_ |
| 7 |
| 8 #import <UIKit/UIGestureRecognizerSubclass.h> |
| 9 #import <UIKit/UIKit.h> |
| 10 |
| 11 // A specialized gesture recognizer to be used to detect any gesture in the app, |
| 12 // excluding those whose touches are solely on a particular view. |
| 13 // A WindowGestureObserver should be added to the app's main window. |
| 14 // Use the normal -initWithTarget:action: method to create instances of this |
| 15 // class. |
| 16 // This recognizer *never* succeeds and doesn't use the target and action in |
| 17 // the normal way. Instead, as soon as there is a touch event that is not |
| 18 // inside |viewToExclude|, this recognizer will call the given action method on |
| 19 // the target. Then this recognizer will immediately fail and pass the touches |
| 20 // on to other recognizers. |
| 21 // Before the action method is called, |touchedView| will be populated with |
| 22 // a pointer to the view that triggered the call. |
| 23 // In case there are multiple touches that simultaneously trigger this |
| 24 // recognizer, only the first touch that is outside of |viewToExclude| will |
| 25 // trigger a call to the action method. There is no guarantee about how "first" |
| 26 // will be determined in this case. |
| 27 // The target and action supplied in the -init will never be called in the |
| 28 // usual way other regognizers call their action methods, and adding new |
| 29 // target/action pairs will silently no-op. |
| 30 // If |viewToExclude| is defined, this recognizer will require all gesture |
| 31 // recognizers on it present at initialization time to fail before receiving |
| 32 // touch events. |
| 33 |
| 34 @interface WindowGestureObserver : UIGestureRecognizer |
| 35 |
| 36 @property(nonatomic, assign) UIView* viewToExclude; |
| 37 @property(nonatomic, readonly) UIView* touchedView; |
| 38 @end |
| 39 |
| 40 #endif // IOS_CHROME_BROWSER_UI_CONTEXTUAL_SEARCH_WINDOW_GESTURE_OBSERVER_H_ |
OLD | NEW |