Carbon C Event Handlers for movement of scroll bar of window - macos

I am trying to find how can we catch the events of that whenever a scroll bar is moved. Scroll bar can also be moved programmatic-ally so, mouse scroll events wont work here.
I am using Carbon, Mac
Thanks,
Rahul

I would try kEventControlIndicatorMoved and/or kEventControlValueFieldChanged.

Related

OSX Accessibility - detecting click on window title bar

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

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!)

NSMenuItem with NSVIew and Key/Mouse Events

I'm using a NSView within a NSMenuItem to allow me to change the padding and menu item height.
Unfortunately the view eats up the scroll wheel and key down/up events as describe in the documentation. However, there doesn't seem to be a way to pass these events back to the menu so it works like before where Key up/down would change the highlight selection, and the mouse wheel would scroll the list if it is too long. Has anyone come across a solution?
Edit:
This is not the same as the duplicate. I can already get the mouse up/down events for the custom view. My problem is that I have no way to pass these events back to the menu to do what it used to do.
For example how do I get the menu to scroll when the menu gets to long in response to a mouse scroll event?
How do I select and highlight the next item on the list in response to a Key Down event. Passing the event to the menu (or any of its superview/window) doesn't do anything, and there are no functions to do something similar that I can see/

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.

How do you make an infinite scrollbar control with Windows Core API?

How do I make one? I am kind of a newbie in Windows API. Is there some sort of manual for this sort of thing? I am specifically interested in a Core API. Thank you for any help.
There are three ways of doing scroll bars: A window's scroll bar; a scroll bar control; or a custom control.
Windows have scroll bars in the non-client (NC) area. These are part of the window frame, and as such they do not have their own window handle or anything.
Scroll bar controls are child window implementations of a scroll bar. Because they are child windows, they offer you a bit more flexibility. You could subclass or superclass one of these controls to implement "infinite" functionality.
The final option is a custom control: you just create your own scroll bar from scratch. Create a single child window, draw it yourself, handle all the mouse and keyboard input yourself, and implement the scroll bar messages yourself. This isn't actually as hard as it may sound.
I'd probably recommend superclassing a scroll bar control. Process the scroll messages in your own scroll bar wndproc, and fall back to the standard scroll bar wndproc for painting and such.
What do you mean with "infinite"?
If you mean a scroll bar where the user can never scroll to the ends, you have to handle the scroll bar's position change notifications and reset the position to the middle.

Resources