Another handy trick used in GUI toolkits is to introduce a "clicked" event created by the toolkit. So simple apps don't need to track button states, only listen for the 'clicked' event and ignore all other events. So a button might receive any of these sequences of events:
Another handy trick used in GUI toolkits is to introduce a "clicked" event created by the toolkit. So simple apps don't need to track button states, only listen for the 'clicked' event and ignore all other events. So a button might receive any of these sequences of events:
press -> appearance changes to depressed
press, release, clicked -> appearance resets and action triggered
press, cancelled -> appearance resets
release -> nothing happens
but typically an app only really needs to act on 'clicked'.