GLBasic forum

Main forum => GLBasic - en => Topic started by: kaotiklabs on 2009-Jul-13

Title: Hijacked mouse in windowed apps
Post by: kaotiklabs on 2009-Jul-13
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?
Title: Re: Hijacked mouse in windowed apps
Post by: MrTAToad on 2009-Jul-13
Mine leaves the window okay - the only time it wont is if you keep resetting the mouse position.
Title: Re: Hijacked mouse in windowed apps
Post by: kaotiklabs on 2009-Jul-13

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

If you are refering to setmouse, Im not using it in the code...
Title: Re: Hijacked mouse in windowed apps
Post by: Moru on 2009-Jul-13
Can you show a slimmed down version of the code that reproduces this?
Title: Re: Hijacked mouse in windowed apps
Post by: kaotiklabs on 2009-Jul-13

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
Title: Re: Hijacked mouse in windowed apps
Post by: MrTAToad on 2009-Jul-14
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.
Title: Re: Hijacked mouse in windowed apps
Post by: Hemlos on 2009-Jul-14
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
Title: Re: Hijacked mouse in windowed apps
Post by: kaotiklabs on 2009-Jul-15

Many thanks mates.

I was not understanding correctly how it works.

Now is solved.  =D