Distinguish Magic mouse/Trackpad scroll event - macos

Inside an Event Tap I need to distinguish the scroll event that comes from a magic mouse to that which comes from a TrackPad.
Does anyone have a solution to this problem? Is there a way to get the product ID of the generating device from the CGEvent? Can IOkit help me here?

Related

Fling right in Xamarin Forms

is there an easyish way in Xamarin Forms to implement a "Swipe Right" event on an item, preferably a row in a grid.
I'm thinking about the way that you delete messages in the GMail app, which also nicely shows the row starting to move before you finish the swipe, so that you can tell that something is about to happen.
If this is in the category of things that is difficult enough that it is better to find a different solution then that would still be useful to know.
Thanks
Cedd
Refer https://github.com/pateljay0323/XamarinFormsGestures
for different gestures like SingleTap, DoubleTap, LongPress, Swipe, Pinch, Move, Up, Down, Unknown

Showing an NSSharingServicePicker on MouseUp

I'm adding sharing to my app (targeting Mavericks, 10.9), which I want to work like this:
User clicks Share button
Cursor changes to crosshair
User drags selection of what he'd like to share
NSSharingServicePicker displays, allowing the user to pick the service to share with
I'm accomplishing this using the -mouseDown:, -mouseDragged:, and -mouseUp: events. mouseDown begins the selection, mouseDragged provides feedback as to the area being selected, and then mouseUp completes the drag, showing the picker. Each time, though, I get this written to the console:
2014-06-25 00:13:45.111 App[31401:303] Warning: -[NSSharingServicePicker showRelativeToRect: ofView: preferredEdge:] should not be called on mouseUp
Please configure the sender with -[NSControl sendActionOn:NSLeftMouseDownMask];
I don't understand why that would be a problem, unless you were showing it from a button click on mouse up. Should I ignore the message? I've tried showing it using dispatch_async and dispatch_after to try and get it to run outside the event's invocation, but they didn't work. I suppose I could ignore it, but does that leave the door to deprecation open?
I know this is a year late but,
I had the same problem. After some research, I cam back with this answer. Before I implemented this code, my button would spin for a while, and then return with the same error you had. When I click my share button now, it no longer lags, and does not return any error. Insert this into your app's awakeFromNib method:[yourShareButtonName sendActionOn:NSLeftMouseDownMask];.
This is what your code should look like:
- (void)awakeFromNib {
[yourShareButtonName sendActionOn:NSLeftMouseDownMask];
}
I hope this helps!

Global mouse event handling similar to MacOsX' build in screenshot functionality

I know there are several questions on Stackoverflow regarding global mouse events in MacOsX and I've spent the last hours searching for one that helped me out.
What I want to create is a functionality that works almost like the build in screenshot functionality of OsX. (Shift+CMD+4)
I want to press a Shortcut and activate the mouse listener with it. Then the mouseDown event should return one coordinate and the mouseRelease event another one. I then want to make a CGRect from them and the eventlistener should be deactivated.
All the codesamples I found give me mouseEvents in a NSView or NSWindow but not global or they give me the location of the mouse coordinate but I've to poll it by myself with a NSTimer. Neither of those is what I need.
As I said: I've spent several hours searching. I've read through many questionthreads and the Apple guide for Cocoa event handling but none of the answers really helped me out.
Thanks for your time!
You will be able to get the global mouse events using
1) CGEvents. Use CGEventTap().
2) From OS X v 10.6, there is a new method :
+ (id)addGlobalMonitorForEventsMatchingMask:(NSEventMask)mask handler:(void (^)(NSEvent*))block

How to capture WM_NCLBUTTONDBLCLK event with wxPython?

I'm using wxPython. I want to detect mouse events on the caption bar. I noticed that there is a event called WM_NCMOUSEHOVER under windows. But I cannot find corresponding event in wxPython. Here is the question, how can I capture those non-client events with wxPython?
I can't find a way to get mouse events from the frame title bar. The closest I got was EVT_MOTION. However, you might be able to use a wx.Timer in combination with wx.GetMousePosition(). See Capturing mouse events outside wx.Frame in Python for more info.

GestureListener select bad item when scroll moves

I saw here and in some articles that I should use GestureListener to get Tap from user then use SelectionChanged. I tried it and I like it. But I have problem with it. When my listbox moves (scrolls) and I try tap I get bad item (I get item from last tap). When I scroll and wait for stopping scroll and then tap everything is fine (I get exactly item which I tap on). Anyone else with this problem? Any solution? Thanks
As (according to your tags) you're targetting 7.1, there is no need to have to use a GestureListener to detect Tap events.
All UIElements in Silverlight 4 (which 7.1 is based on) support a built in Tap event. See http://msdn.microsoft.com/en-us/library/system.windows.uielement.tap(v=vs.95).aspx
Using a GestureListener has an unnecessary performance overhead and can cause other issues as you're discovering.
You should use a Tap event in the individual ListBoxItems or the SelectionChanged event on the ListBox not both.
If you create a new Databound Application, the code in the default project files will show an example of how to use SelectionChanged and in that instance trigger a page navigation.
In future, you may also get a better, faster answer by showing the code you are having problems with, not just describing it.

Resources