[comp.windows.interviews] InterViews 3.0 question

linton@marktwain.rad.sgi.com (Mark Linton) (05/01/91)

In article <3468@kluge.fiu.edu>, ege@scs.fiu.edu (Raimund K. Ege) writes:
|> I am trying to understand the Listener and Handler mechanism in InterViews 3.0.
|> Could anybody enlighten me what I do wrong in the following simple program:
|> all I want is to catch an event that occurs in the application window,
|> the program, however, does not detect any event.
|> 
|> class Test : public MonoGlyph, public Handler {
|>  public:
|>     Test(): MonoGlyph(nil), Handler() {
|>       Label *label = new Label("test",new Font("9x15"),new Color(0,0,0));
|>       body(label);
|>       listener = new Listener(body(), this);
|>       listener->sensor()->button(true,Event::any);
|>       listener->sensor()->key(true);
|>     }
|>     void event(Event&) {
|>       cout << "processing an event\n";
|>     }
|>  private:
|>     Listener *listener;
|> };

Your listener never appears in the glyph dag attached to the window.
You should either derive Test from listener or make Test's body the listener,
where the listener has the label inside it.