Determine if trackpad exists on macOS - macos

Is there an API in AppKit (or elsewhere) to determine if a device has a trackpad connected and enabled? I need my application to enable different behaviours on scroll events depending on whether they are coming from a two finger natural scroll gesture on a trackpad or from a vertical only scroll on a traditional mouse.
Going over the documentation, I cannot find anything and Googling didn't seem to reveal anything either.
I am using an event tap currently to receive events (also, please note that I have very little native macOS development experience so don't assume a lot of prior knowledge)

Turns out a solution to part of my problem (which is highlighted by Willeke in the comments above) can be found here: https://stackoverflow.com/a/42747641/56242
Since that doesn't offer a solution for checking if a trackpad is enabled on the system, I will not mark this as the accepted solution, even though it turns out it works for my particular use case, since someone else might come across this question and that solution doesn't fit their

Related

Why is moving a GUI window from the code discouraged?

Well, the title almost says it all : Why should I not move a GUI (e.g. Gtk) window on screen from the code ? In Gtk 3 there was an API for moving windows on screen, but it was removed in Gtk 4, because it is not good to move a window from code; only the user should do so (don't ask me to provide sources for that, I read it somewhere but have forgotten where and cannot find it). But I cannot think of any reason why it shouldn't be good, but of several reasons why it could be good, for example to restore the position of a window between application restarts. Could you please shed some light on this ?
The major reason why is that it can't possibly work cross-platform, so it is broken API by definition. That’s also why it was removed in GTK4. For example: this is impossible to implement when running on top of a Wayland session, since the protocol doesn't allow getting/setting global coordinates. If you still want to have something similar working, you'll have to call the specific platform API (for example, X11) for those platforms that you want to support.
On the reason why it’s not supported by some display protocols: it’s bad for UX and security. In terms of UX: some compositors can have special behavior because they need to work on a small device, or because they have a kiosk mode in which everything should always run fullscreen, or they provide a tiling experience. Applications positioning their windows themselves then tend to give unexpected behaviour. In terms of security: if you allow this, it’s technically possible for an application to reposition and resize itself so that it covers your screens while making itself transparent, without it being noticeable, which means it has the possibility of scraping all input.

Scrolling in Microsoft Remote Desktop on a Mac w/ Magic Trackpad 2

I'm experiencing wonky behavior using a Mac to remote into a Windows 7 PC using Microsoft's Remote Desktop app for the Mac, and using a Magic Trackpad 2 as my primary input device. The problems arise primarily when scrolling in various applications in Windows. It appears the Magic Trackpad is flooding windows with scroll events, causing unpredictable behavior in many applications. Some scroll ok, others whip around or back and forth, or stutter uncontrollably. I probably need to find a way to "filter" out this flood of scroll events into something more manageable by Windows, but I am unaware of any existing apps or utilities to do so? Has anyone else experienced this issue and/or have any potential solutions to it?
A bit more research, and I've got at least a partial solution to the issue. It helps greatly to turn off some of the "Magic" Apple imparts to its trackpads. Namely, turning off 'scrolling with inertia' helps with scrolling when using Remote Desktop. The default functionality for magic trackpad scrolling is to apply inertia to your scroll, making pages continue to scroll after you release the pad like they have weight. While this looks and feels cool, it wreaks havoc with some older windows apps. The trick is to turn this feature off you have to open the Mac's Accessibility control panel, not the one for the trackpad itself. Within Accessibility there are additional mouse and trackpad tweaks, one of which is to turn off inertial scrolling. Also, reducing the scrolling speed to its lowest setting makes Remote Desktop scrolling a bit easier. Hope this helps others.
One of a kind workaround that I came up recently is to decrease the number of lines for one notch of the mouse wheel.
P.S. For some reason the "Wheel" tab is not visible when I'm connected via MS RDP client, but available for the beta version (Version 10.1.5 (866)).
On the Mac side, pay attention to the speed part in the trackpad settings. Here I suggest you bring it to the fastest. Also, in the remote (windows) machine, increase the line per speed from default 3 to 10 And again, on the windows side, set the mouse speed to the fastest in the additional options section.

What should the parent app for a keyboard-extension in iOS8 do?

Most other extensions have functionality (such as photo-editing, posting to social networks, etc) for which it makes sense to have a parent app.
But for the simplest of keyboard extensions, without any (user-facing) data management or other requirements, I don't understand what the parent app should do.
Just having a "Hello" splash screen seems like a cheat. But is this what Apple expects, at least when it comes to keyboard apps (the simplest ones)?
P.S:
Considering the documents are openly available here, I hope there won't be an NDA issue blocking this question.
I'm not sure if there is another SE sub-site on which this question is more appropriate. However, if necessary, I'd be glad to move the question.
I was looking for a keyboard-specific tag, but none seemed right. UIKeyboard seems specific to the earlier "default" iOS keyboard.
Since the keyboard needs an app, maybe use it as a way for users to try your keyboard without exposing content from other apps to it, at first. It might be important for you to teach users how to use your new keyboard.
Also, since Apple is emphasizing privacy (especially since the potential for key logging keyboards may seem high to the user), you also could display a privacy policy in your demo app. Or at least have an explanative mention of what you do with their typed text other than entering it into the whatever app your keyboard is currently running in.

Xcode SDK & Trackpad gestures: animations setup

Q The question is, is there a way to disable the animations happening with the trackpad-gestures at the currently public-available Xcode 4.3.2 running MacOS 10.7.3 ?
Description I'm very concerned with the new Lion animations while going forward/back with a trackpad gestures. With a keyboard shortcuts the page changes instantly and with a gesture it takes about a second or two spraying around my concentration on the things that need to be found in the code.
Tried What i tried is to read the defaults in the Terminal looking for any animation/duration keys - without success.
Notes Looks like mr. Cook criticizes the things Apple is doing itself while preparing the combined mobile/stationary look&feel. If there's any startup project that collects all the user's customizing, i'll be glad to know. So far i tried the itweax application, it doesn't have yet the expected features however.
Safari stuff is not as much about the content importance, so i would not mind to leave the Safari animations, but changing it on the system level for all the apps is also good.
PS I believe that is about the “software tools commonly used by programmers” mentioned at “What kind of questions can I ask here?” SO FAQ section.
Don't know about disabling animations but if you want to trigger app keyboard commands through gestures, I found BetterTouchTool helpful with some of the major Lion annoyances. Ex. I was able to configure FireFox to do Home/End on a 3-finger swipe up/down.
No, there is no way to disable the animation.
You can, however, disable the page swiping functionality:
System Preferences > Trackpad > More Gestures > Deselect "Swipe between pages"
Unfortunately, there is no setting to disable or change the speed of the animation.

Window docking advice for Mac

I'm from a Windows programming background when writing tools, but have been programming using Carbon and Cocoa for the past year. I have introduced myself to Mac by, I admit it, hiding from UI programming. I've been basically wapping my OpenGL code in a view, then staying in my comfort zone using my platform agnostic OpenGL C++ code as usual.
However, now I want to start porting one of my more sophisticated applications to Mac OS.
Typically I use the standard Visual Studio dockable MDI approach, which is excellent, but very Windows-like. From using a Mac primarily now for a while, I don't tend to see this sort of method used for Mac UIs. Even Xcode doesn't support the idea of drag and drop/dockable views, unfortunately. I see docked views with splitter panels, but that's about it.
The closest thing I've seen to the Visual Studio approach is Photoshop CS4, which is pretty nice.
So what is the general consensus on this? Is there are more Mac-like way of achieving the same thing that I haven't seen? If not, I'm happy to write a window manager in Cocoa myself, so that I can finally delve in an learn what looks like an excellent API.
Note, I don't want to use QT or any other cross-platform libraries. The whole point is that I want to make a Mac app look like a Mac app, leave the Windows app looking like a Windows app. I always find the cross-platform libraries tend to lose this effect, and when I see a native Mac UI, with fancy Cocoa transitions and animations, I always smile. It's also a good excuse for me to learn Cocoa.
That being said, if there is an Open Source Cocoa library to do this, I'd love to know about it! I'd love to see how someone else achieves this, and would help smooth the Cocoa learning curve.
Cheers,
Shane
UPDATE: I forgot to mention a critical point. I support plugins, which can have their own UI to display various plugin specific information. I don't know which plugins will be loaded and I don't know where their UI will live, if I don't support docking. I'd love to hear people's thoughts on this, specifically: How do I support a plugin view architecture, if the UI can't change? Where do I put the plugin views?
Coming from a Windows background, you feel the need to have docking windows, but is it really essential to the app? Apple's philosophy (in my opinion) is that the designer knows better than the user how things should look and work. For example, iTunes is a pretty sophisticated app, but it doesn't let you change the UI around, change the skin, etc., because Apple wants to keep it consistent. They offer the full view, the mini player, and a handful of different viewing options, but they don't let you pull the source list off into a separate window, or dock it in other positions. They think it should be on the left, so there it stays...
You said you "want to make a Mac app look like a Mac app", and as you pointed out, Mac apps don't tend to have docking windows. Therefore, implementing your own docking windows is probably a step in the wrong direction ;)
+1 to Ken's answer.
From a user perspective unless its integral to the app like it is in Adobe CS or Eclipse i want everything as concise as possible and all the different options and displays out of my way so i can focus on the document.
I think you will find with mac users that those who have the "user skill" to make use of rearranging panels will in most cases opt for hot key bindings instead, and those who dont have that level of "skill" youre just going to confuse.
I would recommend keeping it as simple as possible.
One thing that's common among many Mac apps is the ability to hide all the chrome and focus on your content. That's the point behind the "tic tac" toolbar control in the top right corner of many windows. A serious weakness of many docking UIs is that they expect you to have the window take up most of the screen, because the docked panels can obscure content. Even if docked panels are collapsable, the space left by them is often just wasted and filled with white space. So, if you build a docking panel into your interface, you should expect it to be visible most of the time. For example, iTunes' source list is clearly designed to be visible all the time, but you can double-click a playlist to open it in a new window.
To get used to the range of Mac controls, I'd suggest you try doing some serious work with some apps that don't have a cross-platform UI; for example, the iWork apps, Interface Builder or Preview. Take note of where controls appear and why—in toolbars, in bottom bars, in inspectors, in source lists/sidebars, in panels such as IB's Library or the Font and Color panels, in contextual HUDs. Don't forget the menu bar either. Get an idea of the feel of controls—their responsiveness, modality, sizing, grouping and consistency. Try to develop some taste—not everything is perfect; just try iCal if you want to have something to make fun of.
Note that there's no "one size fits all" for controls, which can be an issue with docking UIs. It's important to think about workflow: how commonly used the control would be, whether you can replace it with direct manipulation, whether a visible indication of its state is necessary, whether it's operable from the keyboard and mouse where appropriate, and so forth. Figure out how the control's placement and behavior lets the user work more efficiently.
As a simple example of example of a good versus bad control placement and behavior in otherwise-decent applications, compare image masking in OmniGraffle and Keynote. In OmniGraffle, this uses the Image inspector where you have to first click on an unlabeled button ("Natural size") in order to enable the appropriate controls, then adjust size and position away in a low-fidelity fashion with an image thumbnail or by typing percentages into fields. Trying to resize the frame directly behaves in a bizarre and counterintuitive fashion.
In Keynote, masking starts with a sensibly named menu item or toolbar item, uses a HUD which pops up the instant you click on a masked image and allows for direct manipulation including a sensible display of the extent of the image you're masking. While you're dragging a masked image around, it even follows the guides. Advanced users can ignore the HUD entirely, just double-clicking the image to toggle mask editing and using the handles for sizing. It should be easy to see, with a few caveats (e.g. the state of "Edit Mask" mode should be visible in the HUD rather than just from the image; the outer border of the image you're masking should be more effectively used) Keynote is substantially better at this, in part because it doesn't use an inspector.
That said, if you do have a huge number of options and the standard tabbed inspector layout doesn't work for you, check out the Omni Group's OmniInspector framework. Try to use it for good, and hopefully you'll figure out how to obsess over UI as much as you do over graphics now :-)
(running in slow motion, reaching out in panic) Nnnnnoooooooo!!!!!
:-) Seriously, as I mentioned in reply to Ken's excellent answer, trying to force a "Windowsism" on an OS X UI is definitely a bad idea. In my opinion, the biggest problem with Windows UI is third-party developers inventing new and inconsistent ways of presenting UI, rather than being consistent and following established conventions. To a Mac user, that's the sign of a terrible application. It's that way for a reason.
I encourage you to rethink your UI app's implementation from the ground up with the Mac OS in mind. If you've done your job well, the architecture and model (sans platform-specific implementation) should clearly translate to any platform.
In terms of UI, you've been using a Mac for a year, so you should have a pretty good idea of "the norm". If you have doubts, it's best to post a question specifically detailing what you need to present and your thoughts on how you might do it (or asking how if you have no idea).
Just don't whack your app with the ugly stick by forcing it to behave as if it were running in Windows when it's clearly not. That's the kiss of death for an app to Mac users.

Resources