User interfaces often consist of different input devices like buttons, input fields, dialog boxes, sliders and others. The event order generally determines the expected behavior, and this behavior often is not easy to catch in a simple rule.
Is there a generic approach to this type of problem?
As an illustration of how easily an interface can become complex, take an interface with 3 toggle buttons. If the behavior of a button click depends on the state of each button, 2 ^ 3 * 3 = 24 event cases are possible. If the behavior also depends on the event history, the number of event cases grows exponentially.
As a real-life example, look at a wysiwyg text editor that I am working on. I choose the focus/blur event on the editor to enable/disable the editor. Some buttons (widgets) return the focus to the editor immediately, while other buttons open a dialog. In the image below arrows show where the focus should go when clicking on an interface element.
I found managing of focus a tricky issue here, often introducing undesired or counter-intuitive behavior.