[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

1210.0. "Q: using accelerators within dialog_boxes" by ODIUM::ULLETT (Life moves pretty fast ...) Tue Aug 01 1989 10:27

Hi,	I hope someone out there can help explain to a simple_instructor
	wot is happening and/or suggest a neater solution ...
        Consider a simple application to show off accelerators ...
	The examples I've seen (in course matter etc .. do not use
	dialog_boxes nor UIL !).
	We have the following hierarchy ...

		toplevel
		    |
                main_window   <--- simple calculator appl.
    +---------------+--- - - - 
menu_bar..      dialog_box    <--- calc buttons
                    |
    +---------------+--- - - -
dialog_box      dialog_box    <--- arithmetic buttons, numeric buttons etc..
                    |
               push_button(s) <--- these have accelerators (eg. +-/*)associated.


Some strangeness occurs ... When one call to install all accelerators in
Hierarchy is made (eg XtInstallAllAccelerators(main_window,main_window)) then
the observed operation ... Click title bar for focus
                       ... accelerators work ! (pb action occurs)
                       ... Click on pushbutton (pb action occurs)
                       ... accelerators nolonger function (until re-Click on title)

	Focus, however, is NOT lost ... (some printfs proved this)!!

After playing around the following provides more 'regular' operation with mouse
and accelerators ...
The main_window is told thru UIL to accept_focus etc, create callbacks on the
dialog_boxes then build an array of widget_ids for later
XtInstallAllAccelerators(main_window,dialog_boxes) to use just before
XtMainLoop(). 

... Thanx in advance

T.RTitleUserPersonal
Name
DateLines
1210.1LEOVAX::TREGGIARITue Aug 01 1989 13:3828
I suspect the problem is a little different than you think it is.  That is,
that the problem has nothing to do with "clicking", but instead where
you place the mouse cursor.

The reason is not obvious and has to do with the way that the server delivers
keyboard events.  The window that the server places in the keyboard event
is the window with input focus (in your case the Main Window...) EXCEPT
when the mouse cursor is within a child of the focus window, AND that child
has requested keyboard input.  The way that the Intrinsics dispatch events
is to find the widget associated with the window in the event structure,
and "give" the event to that widget.

In your case, the Dialog Box children of the Main Window widget DO ask
for keyboard events (for default button processing).  So, when the mouse
cursor is within one of the Dialog Boxes, the keyboard event will be
delivered to the Dialog Box, not the Main Window.

There are two ways to get this to work the way you want:

1.  Play with the Dialog Boxes translations (if you don't need default
    button or TAB processing) so that the Dialog Boxes don't ask for 
    keyboard events (you probably don't want to try to do this...)

2.  Install all the accelerators on the Dialog Boxes AS WELL AS the
    Main Window widget.  

Leo

1210.2Thanx for the insight !ODIUM::ULLETTLife moves pretty fast ...Thu Aug 03 1989 06:516
Okay guess the easiest for now is to continue Installing on the dialog_boxes ...


Thanks!

1210.3More about keyboard acceleratorsRANCHO::KIMBALLYou&#039;re soaking in it...Tue Aug 15 1989 18:1419
    What a timely subject!  This brings up two more questions which I was
    just about to experiment with:
    
    1. What other widgets besides the MainWindow and DialogBox actually
    	accept focus?                                                 
    
    2. In general, is it necessary to install accelerators on any and all
    	widgets in your application which may have focus at some point?
    
    3. Specifically, if you have text input fields inside a dialog box
    	and still want accelerators to work with your menus, should you:
    		A. Install accelerators on the dialog box?
    		B. Install accelerators on the stext widgets?
    		C. Install accelerators on the main window?
    		D. Some of the above
    		E. All of the above
    		F. etc.  :-)
    		

1210.4LEOVAX::TREGGIARISun Aug 20 1989 21:2728
    
>    1. What other widgets besides the MainWindow and DialogBox actually
>    	accept focus?                                                 
 
    Text widget (of course...), and composite widgets which contain a text
    widget (e.g. Command Window widget).  Also note that a MainWindow widget or
    Dialog Box widget won't take focus if one of its descendants is
    a text widget.  They will give it to the text widget.
       
>    2. In general, is it necessary to install accelerators on any and all
>    	widgets in your application which may have focus at some point?
    
    Unfortunately, yes.
    
>    3. Specifically, if you have text input fields inside a dialog box
>    	and still want accelerators to work with your menus, should you:
>    		A. Install accelerators on the dialog box?
>    		B. Install accelerators on the stext widgets?
>    		C. Install accelerators on the main window?
>    		D. Some of the above
>    		E. All of the above
>    		F. etc.  :-)
    		
    It should only be necessary on the text widgets in this case.
    
    Leo
       

1210.5GOSOX::RYANDECwindows MailMon Aug 21 1989 09:0618
>>    3. Specifically, if you have text input fields inside a dialog box
>>    	and still want accelerators to work with your menus, should you:
>>    		A. Install accelerators on the dialog box?
>>    		B. Install accelerators on the stext widgets?
>>    		C. Install accelerators on the main window?
>>    		D. Some of the above
>>    		E. All of the above
>>    		F. etc.  :-)
    		
>    It should only be necessary on the text widgets in this case.

	Unfortunately, you must also install the accelerators on the dialog
	box. It doesn't actually take focus, but because of the grab it
	places on the TAB key, if you don't accelerators will not work if
	the pointer is in the dialog box.

	Mike

1210.6UIL?HPSRAD::KOMARthe (w)hole storyFri Apr 20 1990 15:026
    
    	Could anyone provide a uil example of this stuff?
    
    		Thanks
    			-pk.