A very basic project showing how UI elements (specifically buttons) can be drawn and detected. This uses pen and requires that the stage is clickable. Only the top-most button will be highlighted and do an action when clicked. This is achieved by checking the mouse position as it gets drawn. If the mouse is hovering, store the element ID in a variable. Any elements in front of it will overwrite the value because they are drawn later. To draw only one highlighted button, the result of the frame is stored in a variable to be used in the next frame. This does introduce a 1-frame delay visually but I think is worth it given how simple and expandable the code is. A more advanced implementation was used here: https://scratch.mit.edu/projects/62182952/