Almost all UI frameworks work this way including Android, iOS and Cocoa. They receive events from the OS or window manager (mouse moved, keyboard button pressed, touches moved) and dispatch it to the app. The only difference is how the events are dispatched.