Check the state of the flag in the main loop, say after a image has been drawn and then clear the flag and clear the screen. In this case the button press action will wait to the end of the image drawing.
yes it works
but i wanna add other functions such as delay.
As a starter to check if the interrupt button routine is working OK just switch on a LED in the interrupt handler and switch it off in the main loop. This will show that the button press has been recorded and that it has been actioned in the main loop.There are a few "gotchas" when using interrupts, for example the flag to be set in the interrupt routine should be declared as "volatile". This is because the compiler may create code that sometimes creates a temporary "copy" of the variable rather than the "master" variable. The other "gotcha" is switch bounce, where the switch contacts bounce calling the interrupt routines multiple times and even at a time when the button is released...
I don't have any switches, just screen buttons.