[comp.windows.x] Questions on popups.

milind@aramis.rutgers.edu (Milind Deshpande) (08/17/89)

	I have been playing with popup menus and I have following questions.
Please help me out (for X11R3 and athena widgets).

        I am still not clear why one needs to use XtTranslateCoords()
routine? Why can't one use x_toot and y_root values (instead of x and y
values) from event->xbutton structure?
***********

        Some of the athena widgets have 'actions' [such as set(),
highlight()] listed for them. Are there any such actions for shell
widgets? (Looks as if MenuPopup() and MenuPopdown() are.) Are there any other?
***********

        In my program, I have a button A, which when clicked upon, pops a menu.
To that end, the button uses the following:

        popup_actions = XtParseTranslationTable(
                "<Btn1Down>: set() move_menu() MenuPopup(menu)\n");

                /* move_menu() moves the popup menu shell to the right place */
The popup shell (for the menu) uses following translation:

        popdown_actions = XtParseTranslationTable(
                "<Btn1Up>: MenuPopdown()\n");

and each of the buttons in the menu use the following:

        button_actions = XtParseTranslationTable(
                        "<EnterWindow>: set()\n");

	All this works alright. The problem is that after the menu
pops down, button A still remains in 'active' state (it remains in
foreground color...black). I have to RE-ENTER and EXIT that button, to
bring it to 'inactive' state. This looks quite confusing for a user.
(I have seen this behavior in xpostit program too.)
Since the menu pops up in a 'XtGrabExclusive'
mode (Am I correct?), the button A never gets a 'LeaveWindow' event
(this is needed as per the default action table for the button to execute
reset() action). That's why the re-entering is essential. If I want to
use translation tables, how can I program this to avoid the "problem"?
************

        When I tried to use a XtGrabNonexclusive mode by for the popup
menu by using the following:

        popup_actions = XtParseTranslationTable(
                "<EnterWindow>: set() set_pos() MenuPopup(menu)\n");

        I got the following warning during execution of the program (the
program worked as per the translation table I specified).

"X Toolkit Warning: Pop-up menu creation is only supported on ButtonPress or
EnterNotify events."
        What does this mean?
*************

        Thanks a lot.
ilind@alux5.att.com
(Milind Deshpande)

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (08/25/89)

>         I am still not clear why one needs to use XtTranslateCoords()
> routine? Why can't one use x_toot and y_root values (instead of x and y
> values) from event->xbutton structure?

If you want to implement a true popup menu, this method will be fine.  
XtTranslateCoords() is needed if you want to pop up your menu relative
to something else (e.g.  a pull-down menu).

>        Some of the athena widgets have 'actions' [such as set(),
> highlight()] listed for them. Are there any such actions for shell
> widgets? (Looks as if MenuPopup() and MenuPopdown() are.) Are there any other?

Nope.

> (Looks as if MenuPopup() and MenuPopdown() are.) Are there any other?

Nope, these are global actions that can be used with any widget.  They are
not shell actions.

> ...the button A never gets a 'LeaveWindow' event...
> ...how can I program this to avoid the "problem"?

This is an instrinsics mis-feature, and will be fixed in R4.  

> "X Toolkit Warning: Pop-up menu creation is only supported on ButtonPress or
> EnterNotify events."
>         What does this mean?

It means that popuping up your menus using MenuPopup() is not supported
on an enter-window event.  You must use a button or keypress event with
menu popup.  It looks like the error message is incorrect.

						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213

andrew@wuibc.UUCP (Andrew Loth) (08/27/89)

In article <8908241900.AA29986@expo.lcs.mit.edu> kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) writes:
>
>
>> "X Toolkit Warning: Pop-up menu creation is only supported on ButtonPress or
>> EnterNotify events."
>>         What does this mean?
>
>It means that popuping up your menus using MenuPopup() is not supported
>on an enter-window event.  You must use a button or keypress event with
>menu popup.  It looks like the error message is incorrect.
>
>						Chris D. Peterson     
>						MIT X Consortium 

According to the documentation (X Toolkit Intrinsics - C Language Interface, 
section 5.4) MenuPopup IS supported on EnterWindow events:

	If MenuPopup is invoked on EnterWindow ( possibly with modifiers ),
	the translation manager pops up the shell wqith grab_kind set to
	XtGrabNonexclusive and spring_loaded set to False. Otherwise, the
	translation managergenerates an error.

The action procedure in TMstate.c appears to do what the documentation says.
This warning message is caused  by a problem in the _XtRegisterGrabs procedure
in TMstate.c, which is called during the initialization of widgets.  This
doesn't prevent the action from working, it only prints out the warning and
continues as if nothing wrong happened (which is the case).  You can get 
rid of this warning by adding a 'case EnterNotify: break;' line to the end of
the switch statement in _XtRegisterGrabs (before the 'default:').

Andrew T. Loth		andrew@wubcl.wustl.edu
Biomedical Computer Laboratory
Institute For Biomedical Computing
Washington University, St. Louis, MO

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (08/28/89)

> According to the documentation (X Toolkit Intrinsics - C Language Interface, 
> section 5.4) MenuPopup IS supported on EnterWindow events:

> 	If MenuPopup is invoked on EnterWindow ( possibly with modifiers ),
> 	the translation manager pops up the shell wqith grab_kind set to
> 	XtGrabNonexclusive and spring_loaded set to False. Otherwise, the
>	translation managergenerates an error.

You are absolutely right on this one. I don't know why I as thinking of KeyPress
events.

The behavoir that you describe sounds like a bug.  If you send in a bug report
on this to xbugs@expo.lcs.mit.edu using the format shown in
'doc/bugs/bug-report' in the R3 tape we will make sure that it gets on out
list of bugs that need to be fixed.


						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213