Hijacked mouse in windowed apps

Previous topic - Next topic

kaotiklabs

Hi,

I?m programming a little app for windows platforms.
I?m using a 512x384 res.

When I?m executing the app, the mouse cannot leave the game window borders.
I?ve checked my code and I?m not drawing the mouse in any weird way.

is this the usual behaviour in windowed applications or am I missing something?
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

MrTAToad

Mine leaves the window okay - the only time it wont is if you keep resetting the mouse position.

kaotiklabs


Sorry, can you explain it a bit? I dont catch you.

If you are refering to setmouse, Im not using it in the code...
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Moru

Can you show a slimmed down version of the code that reproduces this?

kaotiklabs


Of course, mates.

Code (glbasic) Select
SETSCREEN 512,384,0

GOSUB main

FUNCTION DrawMouse:
MOUSESTATE mx, my, b1, b2
PRINT "<=", mx, my
  IF b1 THEN END
ENDFUNCTION

SUB main:
WHILE TRUE // Endless loop
  DrawMouse()
  SHOWSCREEN
WEND
ENDSUB
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

MrTAToad

#5
QuoteIf you are refering to setmouse, Im not using it in the code...
No, but you are using MOUSESTATE which only works when the mouse pointer is within a window.
Activate the systempointer, and you'll see that MOUSESTATE limits its position to within said window :

Code (glbasic) Select
SETSCREEN 512,384,0
SYSTEMPOINTER TRUE
GOSUB main

FUNCTION DrawMouse:
MOUSESTATE mx, my, b1, b2
PRINT "<=", mx, my
  IF b1 THEN END
ENDFUNCTION

SUB main:
WHILE TRUE // Endless loop
  DrawMouse()
  SHOWSCREEN
WEND
ENDSUB


You'll notice that the mouse pointer can move freely outside the window, but your PRINT statement will stay within the window.

Hemlos

#6
If you use SYSTEMPOINTER TRUE

You wont need to draw your mouse....youll have the windows mouse on top.
You still need to use mouse position detection though:
MOUSEAXIS or MOUSESTATE
Bing ChatGpt is pretty smart :O

kaotiklabs


Many thanks mates.

I was not understanding correctly how it works.

Now is solved.  =D
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!