[comp.windows.x] XmText inside BulletinBoard

luiw@silvlis.com (Hok Lui Wong) (10/25/90)

I have this problem right now:

When I create an XmText widget inside a XmBulletinBoard,
<key>Return works.  That means XmNactivateCallback is
called by activate().

But when I create an XmText widget inside a BulletinBoardDialogShell,
<key>Return does not work.  That means XmNactivateCallback is not called.
Then I redefine the translation for <key>Backspace to acitvate().  
In this case, XmNactivatecallback is called by activate().

Could anybody explain why the <key>Return doesn't work in the
second case?
--
--------------------------------------------------------------------------
Hok Lui Wong                      Internet:  luiw%silvlis.com@sun.com
Silvar-Lisco                      UUCP:      {pyramid,sun}!silvlis!luiw
703 E. Evelyn Ave., CA 94086      Telephone: +1 408 991-6098

nazgul@alphalpha.com (Kee Hinckley) (10/27/90)

In article <1990Oct25.013901.7277@silvlis.com> luiw@silvlis.com (Hok Lui Wong) writes:
>I have this problem right now:
>
>When I create an XmText widget inside a XmBulletinBoard,
><key>Return works.  That means XmNactivateCallback is
>called by activate().
>
>But when I create an XmText widget inside a BulletinBoardDialogShell,
><key>Return does not work.  That means XmNactivateCallback is not called.
>Then I redefine the translation for <key>Backspace to acitvate().  
>In this case, XmNactivatecallback is called by activate().
>
>Could anybody explain why the <key>Return doesn't work in the
>second case?

There is no such thing as a BulletinBoardDialogShell (that would make
sense!). There are DialogShell's and there's BulletinBoard.  In 1.0
BulletinBoard installs the activate translation on the text widget if
its parent is a dialogshell.  If you don't use the intermediate bulletin
board you'll have to install the translation yourself.
-- 
Alphalpha Software, Inc.	|	motif-request@alphalpha.com
nazgul@alphalpha.com		|-----------------------------------
617/646-7703 (voice/fax)	|	Proline BBS: 617/641-3722

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.

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

In article <1990Oct25.013901.7277@silvlis.com> luiw@silvlis.com (Hok Lui Wong) writes:
>When I create an XmText widget inside a XmBulletinBoard,
><key>Return works.  That means XmNactivateCallback is
>called by activate().
>
>But when I create an XmText widget inside a BulletinBoardDialogShell,
><key>Return does not work.  That means XmNactivateCallback is not called.
>Then I redefine the translation for <key>Backspace to acitvate().  
>In this case, XmNactivatecallback is called by activate().
>
>Could anybody explain why the <key>Return doesn't work in the
>second case?

I've been waiting to see how many times I could repost this per week.
      >>>>>>>>>> Hey OSF -- this is a problem! FIX IT <<<<<<<<<<<<<<

From: mayer@hplabsz.HPL.HP.COM (Niels Mayer)
Newsgroups: comp.windows.x.motif
Subject: Re: XmText activateCallback not called in Popup
Message-ID: <6099@hplabsz.HPL.HP.COM>
Date: 22 Oct 90 19:55:54 GMT
References: <KDOSHI.90Oct21215002@ketan.oracle.com>
Reply-To: mayer@hplabs.hp.com (Niels Mayer)
Organization: Hewlett-Packard Labs, Software & Systems Lab, Palo Alto, CA.
Lines: 80
Summary:
Expires:
Sender:
Followup-To:

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.
				   *