Actions

One of the more tedious aspects of GUI development is keeping the UI in sync with the state of the application -- enabling and disabling widgets depending on the current context. For example, if the focus is on a read-only widget you should disable the paste button, once data has been entered you need to enable the File->Save menu item, etc.

Over the years I've learned that this can be a maintenance nightmare. For example, your application may start out with just a File->Save menu. Later you add a toolbar and right-click menu. Then you add keyboard accelerators. Each time you do this you have to find the places in your code where you disable the File->Save menu item and add code to disable all the other widgets and menu items.

Actions are a way to solve that problem. In early 2004 Bryan Schofield posted an implementation of actions to comp.lang.tcl. I had personally been using actions for a few years already and was amazed to find that his code was remarkably similar to my own concept of actions. It wasn't long before a wiki page on actions was created.

A Tcl conference was coming up, and since I'm a huge fan of actions and had been looking for a good excuse to describe them in a bit more detail I decided to submit a paper. Unfortunately I wasn't able to attend and present the paper, but if you want to read it I've made it available here [1]. Check it out, and check out the wiki page [2] too.

1: Tcl'2004 Paper
2: Wiki page on Actions