To stop the cursor from clipping through walls you need to use a loop to check all positions between the old mouse position to the new position for a collision.
like this or the attached capx:
repeat distance(cursor.x, cursor.y, mouse.x, mouse.y) times
---- cursor: move 1 pixel at angle angle(cursor.x, cursor.y, mouse.x, mouse.y)
-------- system: pick wall overlapping cursor.x, cursor.y
-------------- cursor: move -1 pixel at angle angle(cursor.x, cursor.y, mouse.x, mouse.y)
-------------- stop loop
There are other ways such as doing a raycast from the old mouse position to a new one but c2 has nothing built-in for that. You could also do wall sliding for a more pleasing motion instead of getting stuck on walls, but again there's nothing built in to handle that.