UI Elements must be this old, to ride
The basics of a UI event framework is quite simple to understand. There is an event queue that reads user inputs, clicks, types mouse moves, (these days swipes) etc., and the code posts the events to a UI element, a button say, and tells it "Hey, button1, something happened!" The button then can decide if it wants to do something with the event or not.
As a programming idea this works well. I only have one small tweak, that will make a big difference to all UX on all platforms: Before a UI element is allowed to receive an event, it must be of a certain age. Hundred milliseconds, say. This is simply because a UI typically, is used by a slow human brain, that can't read the dialog box, that has only finished drawing on the screen 5ms ago. So why accept input from the user if you are rather sure she doesn't know what she is doing.
Firefox has recognised that this is a potential security problem, and have built in a delay on all plug-in install confirmation buttons. Before that safeguard, one unlucky double click on the wrong spot, could lead to an infected PC.
Most recently the keyboard version of this has happened to me in FTL. Pressing the 1 and 2 keys targets weapon 1 or 2. Only problem is, that 1 and 2 is also the game choice dialog popup's choice short cut keys. So when I thought I would launch the final missile by pressing 2 to destroy the pirate spaceship, what I have actually done is graciously accept their offer of truce, and going our separate ways... No scrap for me.
UIs are supposed to work on a Human pace. Let's give their poor brains time to catch up.