Mouse-Over-Handling in Quorridors
In my first Version of Corridors (the Three.js one), and in the original Game of Dungeons&Diagrams, the add/remove of a wall happens on mouse pressed (as opposed to clicked or released). The player can then move the mouse around and “paint” the wall without having to click each tile. When the first click removes a wall, the player can only remove walls while the mouse is pressed, and vice versa. This is vital for levels larger than 3x3 or 4x4.
There are two flags “isInAddMode” and “isInRemoveMode”, and if a pressed hover is detected, I have to add/remove a wall in the field depending on the flags.
In QtQuick, a MouseArea-Object will not detect a mouse-entered-event while the mouse-button is pressed. This is needed for the painting to work, though.
I usually don’t prefer adding mouse-handlers to large container-elements that contain lots of clickable areas, but in this case there was no other way. I added one large MouseArea, that tracks the mouse and sets a proxy mouse-position property, so that I’m not dependent on the single MouseAreas event-reporting.
The tiles are constantly checking if the proxy mouse-position is overlapping them, which also works fine if the button is pressed. This way I can simulate a pressed hover.