You can see a part of the widget tree for the Unix xcalc program here . This tree was created by the editres program, a utility that you get with every reasonable X distribution. There are two mechanisms in X for this, callbacks and events . An event is something that occurs as a result of a user's action, for example moving the mouse or pressing a key. It is possible to register an event handler with a widget, thus instructing the program to call a specific procedure when a certain event occurs.
Callbacks work much the same.
Basically, callbacks are a layer on top of events. Multiple events can trigger the same callback, and the user does not have to worry whether the button press callback was triggered by a keystroke or a mouse click. If you do want to worry about that, you should use events. If X11 is installed well on your system, a myriad of man pages will be available. Now that we have all that straight, we can proceed to writing our first X program.