Page 1 of 1

Using a canvas to catch mouse and keyboard events in windowed screen

Posted: Mon May 22, 2023 7:27 pm
by Josepho
Hi guys im having a problem, i have a program that needs the more speed the better and what im doing in order to get this speed is using a windowedscreen, the point is that i dont want to use initmouse cause it traps the mouse inside the screen so what im using is a canvas gadget being displayed behind the windowed screen in order to grab this interactions.

I manage to make the canvasgadget being displayed behind the windowedscreen easily

OpenwindowedScreen(windowID(#mainWindow),360,85,etc..)
CanvasGadget(#mapCanvas,360,85,etc)

the problem is that some times when im interacting with the windowed screen it looks like the canvas appears for a second showing a white flash that is very annoying, is there any way to avoid this? Or is there any way to hide the canvas and make it still active somehow?

Many thanks

Re: Using a canvas to catch mouse and keyboard events in windowed screen

Posted: Mon May 22, 2023 7:34 pm
by mk-soft
No gadgets should be used in the WindowScreen area. An overlapping of gadgets in the screen area always leads to problems.

What do you want to use WindowScreen for anyway?

Re: Using a canvas to catch mouse and keyboard events in windowed screen

Posted: Mon May 22, 2023 7:36 pm
by Josepho
Im making a tilemapper and the canvasgadget dies when displaying large maps with several layers, im afraid even the screen gadget isnt enought or maybe its cause the back canvas is making the fps drop?

Re: Using a canvas to catch mouse and keyboard events in windowed screen

Posted: Mon May 22, 2023 7:46 pm
by mk-soft
Leave out the CanvasGadget and use sprites

Re: Using a canvas to catch mouse and keyboard events in windowed screen

Posted: Mon May 22, 2023 7:49 pm
by Josepho
But how to catch mouse interactions and keyboard events and also allowing to move the mouse out of the windowedscreen?

Re: Using a canvas to catch mouse and keyboard events in windowed screen

Posted: Mon May 22, 2023 11:10 pm
by wombats
When you’re drawing with the CanvasGadget, are you trying to draw the entire map or just the tiles that can actually be seen?

You could also look at the OpenGLGadget as it supports the same events as the CanvasGadget, but you’d need to use OpenGL commands to draw everything.

Re: Using a canvas to catch mouse and keyboard events in windowed screen

Posted: Mon May 22, 2023 11:12 pm
by Josepho
Im drawing only the tiles that are seen but as the user can make zoom out the amount of tiles that can be seen sometimes is a lot. Many thanks for the suggestion, i think ill try with the OGL method