Treating User Interface (UI) Widgets Like Finite State Machines