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

Just starting out? Need help? Post your questions and find answers here.
Josepho
User
User
Posts: 65
Joined: Thu Oct 22, 2020 7:01 am

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

Post 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
User avatar
mk-soft
Always Here
Always Here
Posts: 6204
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

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

Post 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?
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Josepho
User
User
Posts: 65
Joined: Thu Oct 22, 2020 7:01 am

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

Post 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?
User avatar
mk-soft
Always Here
Always Here
Posts: 6204
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

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

Post by mk-soft »

Leave out the CanvasGadget and use sprites
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Josepho
User
User
Posts: 65
Joined: Thu Oct 22, 2020 7:01 am

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

Post by Josepho »

But how to catch mouse interactions and keyboard events and also allowing to move the mouse out of the windowedscreen?
wombats
Enthusiast
Enthusiast
Posts: 716
Joined: Thu Dec 29, 2011 5:03 pm

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

Post 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.
Josepho
User
User
Posts: 65
Joined: Thu Oct 22, 2020 7:01 am

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

Post 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
Post Reply