cocoa mousedown on a window and mouse up in another - objective-c

I am developping a Cocoa application and I have a special need. In my main window, when I mouse down on a certain area, a new window (like a complex tooltip) appears. I want to be able to do:
- mouse down on the main window (mouse button stay pressed)
- user moves the mouse on the "tooltip" window and mouseup on it.
My issue is that the tooltip window does nto get any mousevent until the mouseup.
How can I fix this?
Thanks in advance for your help,
Regards,

And it won't since mouse is tracked by the main window. However, you can process mouseUp in the main window, transform click coordinates into the desktop space, get tooltip window frame and check whether the click occurred on the tooltip. After that, you can send a message to the tooltip window manually.
Or you can try to find another way to implement the final goal :) It is usually better to follow the rules, in this case - mouse tracking.

Related

How to ignore mouse moves over hidden part of NSView?

I have some window which in turn contains an NSView, v1. The view can receive events from mouse, like Mouse Down, Enter, Exit and so on. The view can be overlapped by other view (v2) (modal window not involved).
I want to be able receive events Enter/Exit in v1 when the mouse is over visible part of v1, and ignore those events when the mouse is over hidden region.
How? Enlighten me, please.
Eventually in my case solution was pretty simple: options for NSTrackingArea should include NSTrackingInVisibleRect

Detect mouse cursor icon change in application

I've been looking for awhile now to no avail for this.
What I'm trying to do is find a way to detect if a mouse icon changes when you mouse over something.
For example: If you mouse over a link it changes from the arrow to a finger.
My plan is to grab the ID of a window, and scan it for clickable objects based on the mouse icon changing. I can grab the window, bring it to the front, and move the mouse around by setting the x,y coord of the mouse, but I don't see a way to detect if the mouse has found anything.
I would prefer this to be something built into vb.net, but if I have to use an API I'm fine with that.
The approach is wrong because the concepts are different from what you observe visually.
There's no such thing as "click" -- there's Button Down event (Windows message sent by the GUI subsystem to the application), Button Up event and Mouse Move event. If there were Button Down and Button Up with no or little Mouse Move, then the OS considers this a click.
All events are sent to the window under the mouse cursor hotspot unless the mouse input is captured by the other window.
When the cursor is moved over the window, the OS sends WM_NCHITTEST message to the window to determine, how the window treats the area under the cursor. Based on window's response Windows either performs the window operation (window move or resize etc) or passes mouse-related events to the window procedure. The procedure then decides how to react - do nothing, make visual changes, perform some action etc.
As you can see from the description, cursor change and actual actions are two different loosely related operations. There can be an action without cursor change or cursor change without an action.

NSView regisstering events on first click of mouse (making the app active)

I'm kind of pulling my hair out here. I have a single window application with a NSscrollView and custom NSViews inside of the scroll view. The custom NSViews are registering mouseUP and mouseDown events but my problem is that when the app/window is inactive and you click on it anywhere to make it active the mouseUP and mouseDown events are being triggered in the NSView that you click on.
I overrode the '(BOOL)acceptsFirstMouse:(NSEvent *)theEvent' to return NO just to be sure (i know this is the default.
I can't figure out what I'm doing wrong. I'm principally an iOS developer so my OS X experience is not super extensive. Any input helps. Thanks!
Found the issue. I had a NSTexField on the subview that was capturing the first mouseDown event. Just overlooked it.

ignore mouse event on label inside panel

I am making a custom menu. I am applying colors on panels on mouse enter and mouse leave.
I have labels on these panels, and the mouse enter and leave events work snappy, but as soon as I hover over the label (on/inside) the panel, the mouse leave event is fired. I know I can just do the same thing for the label mouse enter event, but I am doing some other visual stuff, and I need to have the label mouse events totally disregarded. Any ideas?
Thanks in advance.
I eventually just used the menu control, and styled it accordingly. Does the job better than I could with code...

VB.NET Minesweeper issue

I have fully programmed my Minesweeper; however, I was having difficulty trying to get the same result as in the original minesweeper for when a user clicks and moves the mouse around while still right clicking. You may notice that in the original Minesweeper, when a user does as explained, the tiles that the user goes to will then look blank. If the user releases the mouse, the current tile they hovered to will become the clicked tile. In my Minesweeper, the tile I click on is the only one that will look blank, and when I hover over to the next tiles, they do not get blank like the first one I clicked on. Then when I release my mouse button when over to another tile, the very first tile I clicked on is the one that gets uncovered. Here is what I already have used. I have the MouseDown event which checks to see if the game has been started to begin the game timer. It also has some color properties for tiles when I click on them and I set a boolean to true or false depending on the user left or right click. I have the MouseUp event which looks at the boolean to determin what the user had clicked on the mouse so I know if I flag or simply click to uncover. Then I have the MouseEnter and MouseLeave which are needed to yield the proper glow I want for the tiles. What should I do to get the same results as in the original Minesweeper with the MouseDown and MouseEnter into other tiles? I tried many other things such as MouseEnter, MouseMove and MouseHover, but all seem to yield the same crummy result as what I already have.
Just another piece of information, the MouseEvents are built in to a UserControl which I then use as my tile in Minesweeper. It almost as if when an event is active, another one cannot be done at the same time.
You might want to consider, DragOver and Drag related events