Click button "if statement"

That’s what button libraries do
Or study the state change detection examples from the IDE

you might benefit from studying state machines. Here is a small introduction to the topic: Yet another Finite State Machine introduction