hittest

Problem with VisualTreeHelper.HitTest in WPF

自作多情 提交于 2019-11-27 07:55:59
问题 I'm trying to hit-test a bunch of UserControls on a Canvas. I don't want the HitTest() to walk the whole way through the visual tree, so I'm using the FilterCallback to make sure I only hit-test the UserControl. My problem is that the UserControl never hits, it should, but it doesn't. If I use the FilterCallback, I return that it hit nothing. If I let the HitTest run through the visual tree, it skips the UserControl. Here's some code: <Canvas x:Name="Container"> <UserControl> <Grid>

How to test if a point is inside of a convex polygon in 2D integer coordinates?

早过忘川 提交于 2019-11-27 03:58:00
The polygon is given as a list of Vector2I objects (2 dimensional, integer coordinates). How can i test if a given point is inside? All implementations i found on the web fail for some trivial counter-example. It really seems to be hard to write a correct implementation. The language does not matter as i will port it myself. fortran If it is convex, a trivial way to check it is that the point is laying on the same side of all the segments (if traversed in the same order). You can check that easily with the cross product (as it is proportional to the cosine of the angle formed between the

identify face of a cube hit on touches began in Swift-Scene Kit

不问归期 提交于 2019-11-26 23:17:58
问题 I'm tying to create an app with Scene kit to solve Rubix Cube. I've my own dae file for the cube. Upon touches began I have the object that's been hit func tapGesture(sender: UITapGestureRecognizer){ // check what nodes are tapped var p = sender.locationInView(sceneView) var hitResults = sceneView.hitTest(p, options: nil) if hitResults.count > 0 { var hitnode = (hitResults.first)!.node print("\nName of node hit is \(hitnode.name)") //var indexvalue = hitResults.first?.faceIndex //print

Detect touches only on non-transparent pixels of UIImageView, efficiently

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 22:36:11
问题 How would you detect touches only on non-transparent pixels of a UIImageView , efficiently? Consider an image like the one below, displayed with UIImageView . The goal is be to make the gesture recognisers respond only when the touch happens in the non-transparent (black in this case) area of the image. Ideas Override hitTest:withEvent: or pointInside:withEvent:, although this approach might be terribly inefficient as these methods get called many times during a touch event. Checking if a

UIView. Why Does A Subviews Outside its Parent's Extent Not Receive Touches?

旧城冷巷雨未停 提交于 2019-11-26 19:23:35
问题 I have a simple - trivial - UIView parent/child hierarchy. One parent (UIView). One child (UIButton). The parents bounds are smaller then it's child's bounds so that a portion of the child extends beyond the bounding box of its parent. Here's the problem: Those portions of the child outside the bbox of the parent do not receive touches. Only tapping within the bbox of the parent allows the child button to receive touches. Can someone please suggest a fix/workaround? UPDATE For those following

Hit-testing SVG shapes?

浪子不回头ぞ 提交于 2019-11-26 18:53:59
The browsers which have implemented parts of the SVG spec (Firefox etc) do hit-testing for us for free - if I attach a mousedown listener on an SVG object, I get notified whenever the shape is clicked. This is amazing, especially for complex polygon shapes. I'm wondering if there's a way I can utilize this feature for a bit more hit testing. I want to know if a given rectangle intersects any of my SVG shapes. For example, I add 3 complex polygons to my element. Now I want to know if rectangle (40, 40, 100, 100) intersects any of them. Does anyone have an idea how I could possibly hook into the

How do I find the DOM node that is at a given (X,Y) position? (Hit test)

為{幸葍}努か 提交于 2019-11-26 18:04:16
问题 I have the coordinates (X,Y) of a point in an HTML document. How do I determine what DOM node is at those coordinates? Some ideas: Is there a DOM hit test function that I missed, that takes a point (X,Y) and returns the DOM element there? Is there an efficient way to walk the DOM element tree to find the containing element? This seems like it would be tricky because of absolutely positioned elements. Is there a way to simulate an event at a given (X,Y) position such that the browser ends up

unexpected nil window in _UIApplicationHandleEventFromQueueEvent

半世苍凉 提交于 2019-11-26 15:52:41
问题 One of my old apps is not working with iOS8. When I start the app up, and try to tap on the screen anywhere, I get this message in my console: unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIWindow: 0x7fe4d3e52660; frame = (0 0; 320 568); opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7fe4d3e2c450>; layer = <UIWindowLayer: 0x7fe4d3e86a10>> I'm using an old style MainWindow.xib. In the MainWindow.xib is my Window object, as

How to test if a point is inside of a convex polygon in 2D integer coordinates?

早过忘川 提交于 2019-11-26 10:58:45
问题 The polygon is given as a list of Vector2I objects (2 dimensional, integer coordinates). How can i test if a given point is inside? All implementations i found on the web fail for some trivial counter-example. It really seems to be hard to write a correct implementation. The language does not matter as i will port it myself. 回答1: If it is convex, a trivial way to check it is that the point is laying on the same side of all the segments (if traversed in the same order). You can check that

Hit-testing SVG shapes?

狂风中的少年 提交于 2019-11-26 06:39:30
问题 The browsers which have implemented parts of the SVG spec (Firefox etc) do hit-testing for us for free - if I attach a mousedown listener on an SVG object, I get notified whenever the shape is clicked. This is amazing, especially for complex polygon shapes. I\'m wondering if there\'s a way I can utilize this feature for a bit more hit testing. I want to know if a given rectangle intersects any of my SVG shapes. For example, I add 3 complex polygons to my element. Now I want to know if