Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detect mouse leaving application's window in pure QB64
#8
(09-27-2023, 01:53 PM)James D Jarvis Wrote: Isn't the lack of mouseinput the easiest way to tell the mouse isn't in the window?  In the image linked here there are 3 runs of the same little scribble application overlapping. The pixels only get drawn when the mouse is in the top overlapping window.  I'm just a little confused on the reason to track the lack of mouse  input in the window when ... none gets reported if the mouse isn't in the window. Am I missing something?


[Image: image.png]

Hi James D Jarvis
thanks for your feedback!

about 
Quote:Isn't the lack of mouseinput the easiest way to tell the mouse isn't in the window?
I think it is not so simple. Here in the bottom I post an image of  3 different apps (run) of the same program that I have posted here as a program that detects if mouse pointer is out or in the area of the window.
As you can see, all three applications in running show a correct result about the position of the pointer of the mouse. So it seems that mouse information are shared among them.

[Image: image.png]

Moreover if you run this code you can see that also when mouse is out of window of the program after a call to _MouseInput you get back mouse informations like _MouseX and _MouseY, _MouseMovementX and _MouseMovementY.
run this code to verify
Code: (Select All)
Rem it is a code test to detect mouse out of window of application
Option _Explicit

Dim As Long S1, W1, H1
Dim As Integer Xm, Ym, Dxm, Dym, Im, Ox, Oy
W1 = 800: H1 = 600
S1 = _NewImage(W1, H1, 32)

Screen S1

Print "  Dxm             Dym           Xm         Ym"
View Print 2 To 30
Do
    Im = _MouseInput ' here we call a mouseinput queque
    If Im Then ' if mouseinput is true
        Dxm = _MouseMovementX ' we store mousemovementX
        Dym = _MouseMovementY ' we store mousemovementY
        Xm = _MouseX
        Ym = _MouseY
        Print Dxm, Dym, Xm, Ym
    End If
    _Limit 300

Loop Until InKey$ <> ""
End
Now move the mouse out of the window and continue moving mouse ... you'll get back MouseInput informations!

Here a screenshot

[Image: image.png]


I dunno if it is right to get back info about mouse when it leaves the area of window's application. 
I think that it is the actual behaviour of the OS (MS Window). But Someoneelse can test the code in Linux or Mac platforms.
Waiting more feedbacks
Reply


Messages In This Thread
RE: Detect mouse leaving application's window in pure QB64 - by TempodiBasic - 09-29-2023, 01:59 PM



Users browsing this thread: 3 Guest(s)