[comp.windows.x.motif] A plethora of keyboard/dialog bugs become clear

nazgul@alfalfa.com (Information Junkie) (04/19/91)

Try compiling the following program.  You'll get a nice little file dialog
box that prints "Called" every time the "okCallback" is called.  Select and
item, click okay and it prints "Called".  Double click on an item and it
prints "Called".  Move to an item using the keyboard, press return and it
prints "Called"... and then it prints "Called" again.

I don't *know* why it does this, but I have a strong suspicion, because I
ran into the same bug in one of my own dialog boxes.

The list widget has a callback it makes when the default action is performed.
This action can occur either as the result of a double click or pressing return.
DialogBox (aka BulletinBoard as a child of a shell) also has a translation for 
return, it maps that into the equivalent of pressing the default button.  Now 
if you put a list widget in a dialog box, what do you suppose happens?  The
return key first calls the list widget and it performs the default action, which
in this case gets mapped to pressing the return.  Then the dialogbox action
gets called again and the okay callback is called once again.  (Sorry, this
is a little fuzzy, it's three in the morning).

This is a disaster for me because on the first call to okCallback I delete
the widget and my associated data.  On the second call I seg fault.

What I don't understand is why the translation is going to both widgets.
Shouldn't it just go to one or the other?  Or am I totally wrong on this?
Secondly, what's the fix?  The traditional Motif mechanism would be to hard
code into the list widget to notice if one of its parents in the tree is a
dialog box and if so not to make the callback - I hope some realizes that
would be wrong :-).  But I'm not sure what's right.

Alfalfa Software, Inc.          |       Poste:  The EMail for Unix
nazgul@alfalfa.com              |       Send Anything... Anywhere
617/646-7703 (voice/fax)        |       info@alfalfa.com

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.