How do i prevent mouse and touch events from trigger for DisplayObjects below a backdrop - mouseevent

I have several display objects in createjs and event using easeljs i want to prevent from mouse and touch event passing through them.
i want like a easy one liner like .mouseEnabled or .mouseChildren is there something will will prevent any other interaction for the objcts below this. i can try adding all events to a backdrop movieclip which tint background color and prevent default and stopPropogation will that help?
so how to i prevent from any type of interaction taking place in canvas just by placing a displayobject that's like wall which will not allow the other displayobjects from getting click, mouseover or touch events.

You can add obj.mouseEnabled= obj.mouseChildren = false; to any you don't want to receive events.
If you just want to block events with a child on top, simply add a mouse handler to it.
cover.on("click", function(){});
You don't need stopPropagation, since that will only prevent events from bubbling in the current hierarchy (ie, surfacing an event to its direct parent). Events do not "pass through" objects that have mouse handlers on them.
Hope that helps!

Related

How to prevent svg drag on specific element?

I'm using the fantastic svg-pan-zoom plugin (https://github.com/ariutta/svg-pan-zoom) to pan/zoom my svg element, I want to enable the mouse drag to let use move it.
I have a single elemen inside my svg where I want to prevent the drag because it has a click event and when the user clicks on it sometimes it drag the svg element.
The requested behavior is to drag as standard except when the mouse is down on this element.
I already try with event.stopPropagation() and event.preventDefault() but seems that svg-pan-zoom plugin has its own event management.
How can I prevent the mouse drag?
You can have 2 layers (if you don't need to pan/zoom that element).
Or you can still keep all elements zoomed but only some of them listening for events. Just place everything you want to listen for events in one SVG Group element <g> and set it to listen for events.
Last solution would be to override default events for click/drag and write your own handlers.
I would recommend option 1 if you don't need your element to be zoomed, or option 2 otherwise.

Detecting a scroll event in GridView (Windows 8)

How do we detect a scrolling event in GridView (like ViewChanged on ScrollViewer) on somethig like the default GridView template sample app? I'd like to replicate the effect that the netflix App does on the left red strip.
I tried putting the GridView inside a scrollviewer, but I've been unsuccessful at stretching it to fill the screen for different resolutions.
Update: I intend to use this with VariableGrid control that's on NuGet - though it's not an official control, it inherits GridView
The best way to do this seems that you can read through the components of the control, and assign events to it. based on what's happening in this example
http://mikaelkoskinen.net/post/WinRT-XAML-Automatically-Scrolling-ListView-to-Bottom-and-Detecting-When-ListView-is-Scrolled.aspx
I grabbed access to the scrollbar, suing the VisualTreeExtensions and I could capture the event Scroll, just like in the example. I had to read the children when the Loaded event of the grid was fired.
There is a simpler way.
Edit a template of the GridView, and look inside the XAML to find a ScrollViewer which is a component of the GridView.
The ScrollViewer has a ViewChanged event that you can subscribe to. Now whenever the GridView is scrolled, this event will be fired.
Try ManipulationCompleted and PointerReleased events on GridView. This is just using keyboard mouse..

UIButton events. What's the difference?

I've encountered a problem where my button should remain "pressed down" while it shows popover called from it. Popover is selector for some filter and filter is shown on button itself. When I tap on it and it shows popover it becomes deselected no matter what.
I think I have to redefine it's behavior on touch event and make it respond not to standart touch up inside. Then I wondered what are other events responsible for? But I couldn't find events list in iOS library and in StackOverflow are only questions about incorrect behavior of touch up inside or touch down.
So what's the difference betweeen touch events?
touch cancel - when you touch button but move your finger away and
it remains deselected?
touch down - right on tap.
touch down repeat ??
touch drag enter ??
touch drag exit ??
touch drag inside ??
touch drag outside ??
touch up inside - when you tap and release button remaining in it's
bounds . It changes UIButtons state to Normal.
touch up outside - when you tap and release button leaving it's
bounds ?
other IBActions are not sent by UIButton, right?
Also how those events change UIButton's appearance? Like highlighted or selected?
I'd appreciate a link on good article about IBActions, because I couldn't find it.
From Apple's doc for UIControlEvents:
UIControlEventTouchCancel
A system event canceling the current touches for the control.
UIControlEventTouchDown
A touch-down event in the control.
UIControlEventTouchDownRepeat
A repeated touch-down event in the control; for this event the value of the UITouch tapCount method is greater than one.
UIControlEventTouchDragEnter
An event where a finger is dragged into the bounds of the control.
UIControlEventTouchDragExit
An event where a finger is dragged from within a control to outside its bounds.
UIControlEventTouchDragInside
An event where a finger is dragged inside the bounds of the control.
UIControlEventTouchDragOutside
An event where a finger is dragged just outside the bounds of the control.
UIControlEventTouchUpInside
A touch-up event in the control where the finger is inside the bounds of the control.
UIControlEventTouchUpOutside
A touch-up event in the control where the finger is outside the bounds of the control.
Listed in, what I would consider, order of common use/likelihood of occurrence for a normal button:
UIControlEventTouchDown: The user tapped the button. This fires on the finger/stylus making contact.
UIControlEventTouchUpInside: The user tapped the button. This fires on the finger/stylus contact pulled back away from the screen.
Useful for sliders and drag events like moving a component around. The below are in order of occurrence:
UIControlEventTouchDragInside: Triggered as the finger drags into the button area.
UIControlEventTouchDragExit: Triggered during a drag motion. It is called only once, as the users finger/stylus leaves the bounds of the button.
UIControlEventTouchDragOutside: Triggered during a drag motion, after 'UIControlEventTouchDragExit', and is called continuously, as long as the original touch continues.
UIControlEventTouchUpOutside: This is simply the finger/stylus being lifted BUT only if the finger/stylus is no longer within the bounds of the button. The important thing (and probably obviously) to call out is that the touch had to have been within the button at some point to associate this event with the button.
Note: My understanding is that the above can be helpful for:
Sliders: as you might expect the touch may have been intentional but because of the quick swipe action, their finger movement may be sloppy and lift up outside of the slider area.
Moving components around, as when you push things around a screen you want the movement to happen when the finger/stylus touches the border of the component/object.
Other events:
UIControlEventTouchCancel: Something out of the user's control is cancelling their touch action. Think of this as something "going wrong" on the phone side of things.
UIControlEventTouchDownRepeat: Want to detect when your user is mad and tapping a button furiously? Want to detect if they're still in Windows mode and are trying to "double click"? Or maybe you designed a button to do something different if they tap twice. This event helps with all of those!
References:
SO 1: Dif between UIControlEventTouchDragOutside and UIControlEventTouchDragExit
SO 2: What is UIControlEventTouchCancel?

Missing mouse up event from different canvas in smartGWT

I have two canvases located to each other. One is supposed to be a kind of workspace you can add items to, select and rearange them. The other one is just a property view.
What I want to do is to be able to draw a rectrangle on the workspace. As long as the user holds down the mouse button the rectangle will show up. If he releases the button all items that are beneath the rectangle will be selected. This currently works good with the MouseDown, MouseStillDown und MouseUp events. I'm drawing another rectangle shaed canvas on the workspace which will be transformed on every MouseStillDown event and the selection will occur on the MouseUp event. My problem is, that if the user hold down the mouse button and moves it to the property canvas and then releases the button the MouseUp event from the workspace isn't called. Neither is the one from the property since it's missing a MouseDown event. So if the user releases the button there the selection won't work and the rectangle stays in the workspace.
Is there an oppurtunity to somehow avoid this? Or is there a better way to determine the area the user selected with it's mouse while holding down the left mouse button?

Mouse events for an NSSegmentedCell subclass?

I'm trying to implement some rudimentary tabs in a Cocoa editor I'm working on. I am using an NSSegmentedControl and adding segments to it as tabs. I'm using a custom NSSegmentedCell subclass for the tabs to draw a little 'x' icon next to the text for closing tabs and so far it's been going pretty smooth.
However, I cannot figure out how to actually process mouse events for the tabs to check if someone moused over (or clicked) the 'x' icon. I tried overriding "mouseMoved" in my NSSegmentedControl subclass, but for some odd reason it stops getting called when I add a new segment to it (I set "setAcceptsMouseMovedEvents" to yes in awakeFromNib, do I have to also set it somewhere else??). NSSegmentedCells, being NSCell subclasses seem to not have any mouse event processing, aside from mouse tracking, which gets triggered only when the control is clicked.
So the question is, how would I properly process mouse events, either in the NSSegmentedControl or in the NSSegmentedCell subclass?
Take a look at NSTrackingArea. You can add a tracking area to your NSSegmentedControl and get mouse-entered events on that to highlight the close button.
As for getting the click events, you're probably best off using a separate NSActionCell subclass for the close button and do some hit testing there.