Is there a way to know whether a mouse is grabbed or not when using the winit crate? - input

I want to grab it when user clicks on the window and ungrab when Esc is pressed. I could keep a boolean flag in my code but what if the window loses focus in some unexpected way and the mouse becomes released without me knowing about it?

Related

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.

Detect mouse pressed events outside window Processing 2.0

I am trying to find a way where I can click out side of the program's window and have the program pick up any time I press the mouse (Ex: Have Chrome or a game open and every time the mouse button is pressed processing is told the mouse is being pressed). I do not need any information to be sent to the program besides the fact that the mouse button has been pressed.
Thank you

cocoa mousedown on a window and mouse up in another

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.

Keeping window of another application active while still receiving mouse events from another app's window?

Is there a way to have my app's window receive keyboard and/or mouse events (i.e. user clicking on window's buttons) while still retaining focus to another, unrelated app?
I've tried configuring my window at different levels, including [myWindow setLevel:NSPopUpMenuWindowLevel] to no avail.
You should be able to handle mouse clicks without ordering your window front by making your views (at least the ones that handle mouse clicks) respond to acceptsFirstMouse: messages by sending NSApp a preventWindowOrdering message and then returning YES.
You should not make your app handle typing without ordering itself front. The user might not realize where their typing is going if the field where it's appearing is obscured by another window.
Found it. Simple, yet elusive.
Use NSPanel and make sure panel style is Non Activating (NSNonactivatingPanelMask) or tick the same option in IB's inspector.

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