[comp.windows.x.motif] XmText activateCallback not called in Popup

kdoshi@oracle.com (Ketan Doshi) (10/22/90)

Hi all,

I have a Popup dialog box created via XmCreateBulletinBoardDialog.
This popup has in it a couple of single-line XmText widgets. Each of
these text widgets has a XmNactivateCallback defined. As far as I can
make out, hitting Return in a single-line text widget should invoke
this callback, but it doesn't.

The popup dialog is a child of a XmBulletinBoard in the "main window".
The Bulletin Board's parent is a Top Level shell. The Bulletin Board
also has several XmText children. These children also have activate
callbacks defined and DO get invoked when I hit Return.

Why then does the activate callback in the popup not get called ? I
tried adding a translation to the text widget in the popup in case it
didn't inherit the translations from the main window. But it didn't
work.

Any suggestions will be greatly appreciated.

Ketan.


--
#########################################################################
Ketan Doshi						kdoshi@oracle.com
Oracle Corp						(415) 506-6239
Tools and User Interfaces
#########################################################################

mayer@hplabsz.HPL.HP.COM (Niels Mayer) (10/23/90)

In article <KDOSHI.90Oct21215002@ketan.oracle.com> kdoshi@oracle.com (Ketan Doshi) writes:
>I have a Popup dialog box created via XmCreateBulletinBoardDialog.
>This popup has in it a couple of single-line XmText widgets. Each of
>these text widgets has a XmNactivateCallback defined. As far as I can
>make out, hitting Return in a single-line text widget should invoke
>this callback, but it doesn't.
>
>The popup dialog is a child of a XmBulletinBoard in the "main window".
>The Bulletin Board's parent is a Top Level shell. The Bulletin Board
>also has several XmText children. These children also have activate
>callbacks defined and DO get invoked when I hit Return.
>
>Why then does the activate callback in the popup not get called ? I
>tried adding a translation to the text widget in the popup in case it
>didn't inherit the translations from the main window. But it didn't
>work.
>

Motif dialogs have the special "feature" (aka bug) in which they override
the txlation on the return key for widgets parented by a dialog shell. This
is what makes dialogues disappear automatically when you hit "Ok" or
whatever button has been set to default (and therefore activatable by
hitting <return>).

One hack you can do to get normal behaviour back is to explicitly do an
XtOverrideTranslations() on "<Key>Return: activate()" for each single line
text widget you want to do an XmNactivateCallback on.

Here's some code I diddled together in WINTERP to do this.  Translation to
C is a 1-to-1 mapping, based on the names of the WINTERP-Lisp methods and
functions...

				--------------------
(setq toplevel-w			;XtAppCreateShell(topLevelShellWidgetClass)
      (send TOP_LEVEL_SHELL_WIDGET_CLASS :new))

(setq bb-w				;XmCreateBulletinBoardDialog()
      (send XM_BULLETIN_BOARD_WIDGET_CLASS :new :dialog toplevel-w
		       :XMN_DIALOG_TITLE "Form Dialog"
		       ))

(setq edit-w				;XmCreateText()
      (send XM_TEXT_WIDGET_CLASS :new :managed bb-w
	    :XMN_EDIT_MODE       :SINGLE_LINE_EDIT
	    ))

(send edit-w :set_callback :XMN_ACTIVATE_CALLBACK '() ;XtAddCallback()
	'(
	  (format T "foo\n")
	  ))

(send edit-w :override_translations	;XtOverrideTranslations()
      "<Key>Return: activate()")

(send bb-w :manage)			;XtManageChild()

			--------------------

PS: IMHO, The "dialogue" variants of Motif widgets are bad design -- If I
want one or more widgets in a dialog shell I'll put them there myself, and
do XtPopUp() and XtPopDown() on the dialogue-shell explicitly -- as the
Xt-Gods had intended us to. The amount of non-explicit
behind-the-scenes-abstraction-breaking-for-the-sake-of-so-called-convenience
in Motif causes more problems than it solves.  The non-explicit tweaks
caused by Motif dialog variants, and scrolled variants (aka, hidden
scrolled-window parents making XmText and XmList widgets non-polymorphic)
must be the #1 cause of confusion and problems for Motif programmers. At
least I always see the same questions appearing over and over again.
Anybody at OSF listening??

For more info on "The just say no to UIL and Convenience Functions"
foundation, send $1.00 to The OSF/Motif Train-Spotters Guild, 1120 Byron
St, Palo Alto, CA 94301. :-)

-------------------------------------------------------------------------------
	    Niels Mayer -- hplabs!mayer -- mayer@hplabs.hp.com
		  Human-Computer Interaction Department
		       Hewlett-Packard Laboratories
			      Palo Alto, CA.
				   *

tbray@watsol.waterloo.edu (Tim Bray) (10/24/90)

In article <6099@hplabsz.HPL.HP.COM> mayer@hplabs.hp.com (Niels Mayer) writes:
 Motif dialogs have the special "feature" (aka bug) in which they override...
etc...
 PS: IMHO, The "dialogue" variants of Motif widgets are bad design -- If I
 want one or more widgets in a dialog shell I'll put them there myself, and
 do XtPopUp() and XtPopDown() on the dialogue-shell explicitly -- as the
 Xt-Gods had intended us to.
...more intelligent ranting...

Yes.  Yes.  Yes.  I am nowhere near smart enough to figure out all the weird
things that are going on inside Motif's popups.  Roll your own.  If you need
to trap RET and do something with it, do it yourself.  The Xt popup/down
mechanisms are simple and straightforward and work the first time.

Tim Bray, Open Text Systems