OSX Accessibility - detecting click on window title bar - macos

I'm looking for a way how to detect click on NSWindow title bar using Accessibility.
I've implemented observer to get clicks, I'm able to get clicked window, it's origin, size or role + subrole. But is there any way how to be sure I clicked on the title bar, the one used to drag windows?
Cheers

In case anyone is interested I found solution good enough for me.
I check if user clicked within 40 pixels from top of the window and if the role of clicked element is one of the following: AXToolbar, AXSplitGroup, AXGroup, AXScrollArea, AXWindow

Related

How do I prevent the menu bar from moving down when my popover is open?

I have an app with a popover that appears on a status bar item. The thing is, when you click on the icon while you're in a full screen app, then move the mouse away from the menu bar to click on something in the popup, the menu bar moves up, and so does the popup. It's annoying.
Anyone know of any way to solve this? I've tried attaching an invisible menu to the popup, but I can't get the menu to be invisible.
Screenshot for clarity, the annoying part is where I wave my mouse around:
The popover window is moving because its parent window is the status item window, and when the parent window moves, the child moves with it. (Before I investigated this, I didn't even know Cocoa had parent and child windows.) I solved the problem with this code immediately after showing the popover:
NSWindow *popoverWindow = self.popup.contentViewController.view.window;
[popoverWindow.parentWindow removeChildWindow:popoverWindow];
Now, the menu bar still moves up, but at least the popup stays in the same place.
Either use Carbon events or watch for things happening to the menu bar (window of type NSStatusBarWindow):
Notifications of type
NSWindowDidChangeOcclusionStateNotification
NSWindowDidMoveNotification
NSWindowWillCloseNotification
NSWindowDidCloseNotification
with an object of class NSStatusBarWindow should give you enough information about the menu bar showing or hiding to add proper handling.
Super-hacky approach:
Custom window with some super-high window level to make it appear over the menu bar, then add a transparent custom view to the new window that catches and handles/blocks mouse clicks according to your needs.
Or:
Get the window instance the popover is using to display and track/handle NSWindowWillMoveNotification / NSWindowDidMoveNotification.
I converted #tbodt's answer to Swift 4 and confirmed that is resolves this issue:
let popoverWindow = popup.contentViewController.view.window as? NSWindow
popoverWindow?.parent?.removeChildWindow(popoverWindow!)

How do I achieve the UI effect of a window pointing to a status bar item?

I've seen this done on a few apps:
Can anyone suggest a starting point on how to do this? I've done some work with the Interface builder and Cocoa, but nothing this fancy. The requirements are to be able to display a window on demand under a particular menubar icon, and have the user be able to interact with it (buttons and text fields). Not asking for a full blown solution (unless one exists), just a friendly push in the right direction...
Get the icons rect from the status bar, then present your window based on that rect. Your example shows an arrow (from a png background image), then they aligned the arrow to be the center of the icons rect in the status bar.
I stumbled upon this: http://mattgemmell.com/2008/03/04/using-maattachedwindow-with-an-nsstatusitem/
Matt Gemmell made a very nice class for these kinds of windows MAAttachedWindow

How to implement this ejecting and withdrawing portion of a window like a drawer?

How to implement following effect with Cocoa:
<->
User can eject and withdraw right portion of window with a button.
Update: How to draw the vertical line in the tool bar?
This is actually part of the window. When you click the button, the window and view just resize into their appropriate positions.
Check out NSViewAnimation.

How do I build a toolbar in my title bar?

I have to implement a custom toolbar for my application, where a button will be placed on the side of exit, maximize and minimize buttons.
I tried to work with the toolbar element on XCode, but it always put elements below these buttons and not on the side.
App Store application implement this feature, like you can see in this image.
One solution is to start with this open source code (https://github.com/indragiek/INAppStoreWindow) to give you the correct title bar style, and then position buttons in the titlebar.

Windows Phone 7 - Move Content above Keyboard

I have page containing 4 textboxes and a button. The content is within ScrollViewer. When user goes to the last textbox, the button below it is 50% visible. So, to click it, user has to click on non-focusable area to hide the keyboard and then click on button.
Is there any way to move the ScrollViewer up? Or move the content up so that the button below focused textbox can be seen 100%?
The solution is to remove the buttons on the page and replace them with buttons in the ApplicationBar as this is always viewable below the SIP.
If this is not a solution you can implement (from a design view-point there is no reason to not do this but sometimes these decisions come from elsewhere) then you could look to use the ScrollToVerticalOffset method to try and bring the desired item into view.
I would suggest you read Alex Sorokoletov's article on how to transform the view. It might be of help for your problem.

Resources