idea for selecting things

I had an idea, but I don´t know if this is possible: Drawing a square and scale it to the cursor, if the mouse button is released, it´s easy to check the selected things with collision.
Would this work in a way like this?
(I would also like to know how to scale, could somone make a little demo?
)
Would this work in a way like this?

(I would also like to know how to scale, could somone make a little demo?
