On Mon, 2001-09-24 at 11:31, mcmahill mtl mit edu wrote:
Is there a way to get a signal when any text entry or combo box thats in a window has changed without having to attach the signal call back to each widget? My application is I have a program with several entries. When any get changed, I want the window title to get a '*' appended to it. Then when I save my work, I'll get rid of the '*'. I guess I can manually attach the signal to everything, but I didn't know if there was a quicker (and less error prone) way.
The attached solution isn't really a serious suggestion for how to do this, I doubt that it is less error prone, but it is the "obvious" solution that crept into my head when I thought about the problem. The idea is to keep track of children through listening to the add signal on the window. When a child is added, you check whether it is an editable, in which case you connect to the "changed" signal, or whether it is a container, in which case you connect to the "add" signal, to recursively apply this protocol. Then, whenever an editable is added somewhere in the child hierarchy, the "changed" signal is automatically connected to. At least in theory. The problem is that the boxes apparently wont emit the "add" signal if you add children through the _pack methods rather than the add method. I believe this is a bug(?). Anyway, a more serious suggestion is creating the editable widgets in some factory method that takes care of connecting the signal, and only add widgets obtained from the factory. /mailund -- If you can read this, you're in range.
Attachment:
main.c
Description: Text Data