hittest

Hit Test behavior

泪湿孤枕 提交于 2019-12-06 06:50:30
I have the following code public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } List<UIElement> ucs = new List<UIElement>(); private void Window_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ucs.Clear(); Point p = e.GetPosition((UIElement)sender); VisualTreeHelper.HitTest(this, null, new HitTestResultCallback(MyHitTestCallback), new PointHitTestParameters(p)); Console.WriteLine("ucs.Count = {0}", ucs.Count); foreach (var item in ucs) { Console.WriteLine("item: {0}", item.ToString()); } } HitTestResultBehavior MyHitTestCallback

Why is hitTest not being called when views subview is touched?

拥有回忆 提交于 2019-12-06 03:01:18
I have a view which I'll call parentView which has a subview called childView . Part of childView is outside the bounds of parentView , and childView has a panGestureRecognizer attached to it. I have implemented the following in parentView so that it will recognize touches to childView even though it's outside of its superviews bounds: - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { if (!self.clipsToBounds && !self.hidden && self.alpha > 0) { for (UIView *subview in self.subviews) { CGPoint subPoint = [subview convertPoint:point fromView:self]; UIView *result = [subview hitTest

SceneKit, 'hit' testing between camera orientation and geometry

我们两清 提交于 2019-12-05 21:45:18
I'm currently following David Roonqvist's 3D Graphics with SceneKit book. Chapter 5 deals with hit testing, no issues implementing it, but only deals with his testing from mouse events. Now, I know my camera's orientation will ALWAYS intersect a certain geometry. I need to obtain the texture coordinate of the intersecting point between the camera orientation and the geometry. Any pointers as how to go about it? I've been looking all over without much success. Any help is appreciated. I haven't tried this but... SCNHitTestResult returns, among other things, textureCoordinatesWithMappingChannel(

ARKit estimatedVerticalPlane hit test get plane rotation

别等时光非礼了梦想. 提交于 2019-12-05 18:39:09
I am using ARKit to detect walls at runtime, I use a hit test of type .estimatedVerticalPlane when some point of the screen is touched. I am trying to apply Y rotation to node corresponding to the detected plane orientation. I want to compute the rotation in : private func computeYRotationForHitLocation(hitTestResult: ARHitTestResult) -> Float { guard hitTestResult.type == .estimatedVerticalPlane else { return 0.0 } // guard let planeAnchor = hitTestResult.anchor as? ARPlaneAnchor else { return 0.0 } // guard let anchoredNode = sceneView.node(for: planeAnchor) else { return 0.0 } let

Custom shape touchable area

寵の児 提交于 2019-12-05 07:20:35
问题 I have a shape like below and I want set it as background to my UIButton but touchable area is a rectangle, any suggestion to change touchable area to shape boarders? 回答1: The idea is to have a subclass of UIButton that overrides the following methods: func hitTest(_ point: CGPoint, withEvent event: UIEvent?) -> UIView? // that's for handling the case of multiple custom subviews on your view rather than for evaluating if it's your view to handle the touch and func pointInside(_ point: CGPoint

Tap / Select Node in SceneKit (Swift)

大兔子大兔子 提交于 2019-12-04 11:13:02
问题 I'm new to SceneKit and 3D spaces in iOS. I'm currently working on a simple game that shows a cube of 28 segments ("mini cubes" if you want). I want to move the mini cubes by tapping them, but I can't get my head around how to select specific nodes (childnodes of the big cube). Can anybody help me or post a link to SceneKit tutorials for dummies? I've been looking for days now, and haven't found what I'm looking for. Cheers 回答1: You can hit test the scene view (for example from the location

Get tap event for UIButton in UIControl/rotatable view

左心房为你撑大大i 提交于 2019-12-04 02:51:15
Edited See the comment section with Nathan for the latest project. There is only problem remaining: getting the right button. Edited I want to have a UIView that the user can rotate. That UIView should contain some UIButtons that can be clicked. I am having a hard time because I am using a UIControl subclass to make the rotating view and in that subclass I have to disable user interactions on the subviews in the UIControl (to make it spin) which may cause the UIButtons not be tappable. How can I make a UIView that the user can spin and contains clickable UIButtons? This is a link to my project

How can you set IsHitTestVisible to True on a child of something where it's set to false?

允我心安 提交于 2019-12-04 02:30:52
I have a message which is within a border and is displayed in front of a MDI client area. Because it's just a message, I set it's IsHitTestVisible to false. For convenience, I've also included a button within it so the user can simply click the button to start a new diagram. However, because the border has its IsHitTestVisible set to False , it shorts out the True value of the button so the user can't click on the button. That said, how can you make a control invisible to the mouse, while still allowing one of its children to receive mouse events? Here's a screenshot: We want the blue area

Custom shape touchable area

牧云@^-^@ 提交于 2019-12-03 21:38:45
I have a shape like below and I want set it as background to my UIButton but touchable area is a rectangle, any suggestion to change touchable area to shape boarders? The idea is to have a subclass of UIButton that overrides the following methods: func hitTest(_ point: CGPoint, withEvent event: UIEvent?) -> UIView? // that's for handling the case of multiple custom subviews on your view rather than for evaluating if it's your view to handle the touch and func pointInside(_ point: CGPoint, withEvent event: UIEvent?) -> Bool // way more preferable than hit test in your case!!! There is a

Identifying the Type of Touch Gestures from UIEvent Object

*爱你&永不变心* 提交于 2019-12-03 12:50:10
Is there a way to gain the type of touch gestures that triggered a UIEvent? So, let's say I intercept a gesture with hitTest:withEvent:. How do I identify what kind of touch (pinch, tap, swipe, etc.) happened that triggered this method? I can gain the type of remote events from the UIEvent subtype, and even if the device was shaken, but there is no parameter for touch events... How do you identify those? You have to do touch analysis on your own. It is not that difficult, but it is not done for you. Here a sample from some code I am actually using. It is not meant as a full-scale solution. It