[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

1263.0. "Help with focus.." by SPI0::CKALER () Fri Aug 11 1989 10:03

	I am trying to gets some help on setting the focus.

	I have the following basic hierarchy :

			top-level
			    |
		        main window
			    |
                    +-------+------------+
                    |       |            |
		menubar  attachedDB  commandWindow

	What I would like is the following ...

		(1) When I realize the top-level, focus to be assigned to
		    the commandWindow

		(2) When I puck anywhere in the top-level hierarchy, focus
		    to be assigned to the commandWindow.

	I have tries setting the Focus attribute... couldn't seem to make it 
	work right.

	I dug around and found AcceptFocus, but that needs a time argument that
	I can't quite figure out....

	Thanks,

		Christopher Kaler

T.RTitleUserPersonal
Name
DateLines
1263.1CurrentTimeSMAUG::FLOWERSIBM Interconnect Eng. 226-7716Fri Aug 11 1989 12:417
>	I dug around and found AcceptFocus, but that needs a time argument that
>	I can't quite figure out....

You can use the predefined "CurrentTime"....it's defined in x.h

Dan

1263.2SDSVAX::SWEENEYHoney, I iconified the kidsFri Aug 11 1989 13:155
    re: .0
    
    What you are suggesting doesn't conform to the XUI style guide, but I
    suppose it's become pass� to suggest that.

1263.3SPI0::CKALERFri Aug 11 1989 14:4110
  I tried using CurrentTime... but it didn't work.

  As for Style, does the style suggest that the user must puck a one-line
  input region of a 30cm square window in order to specify text input...
  I think that would be sad.  I scanned the XUI style, but did not read it
  in depth.  How are others dealling on this issue?

	Christopher

1263.4PSW::WINALSKIMeetings are our most important productFri Aug 11 1989 15:1717
RE: .3

It is a fundamental part of XUI style that input focus is controlled by the user
(speaking through the window manager) and not by applications.  Your application
should take focus when the user (window manager) gives it to you.  It should not
grab focus simply because the pointer happens to be in one of its windows.

However, once your application has been given focus, it is acceptable for it to
assign input focus to whichever of its widgets it wishes.  If I understand your
application correctly, I would do the following.  Don't key off pointer events
and grab input focus whenever the pointer enters your windows.  Wait for the
event to come in that says the window manager has given your application the
input focus (I don't remember off-hand what this event is called).  When you
get that event, hand off input focus to your command window widget.

--PSW

1263.5Two events to look forREINIG::REINIGThis too shall changeFri Aug 11 1989 16:149
    There are two events to look for:
    
    1. A focusin event on a widget.  
    
    2. A client message to your top widget.  The message type will be a
       DEC_WM_TAKE_FOCUS.
    
                        August G. Reinig

1263.6SPI0::CKALERFri Aug 11 1989 16:3216
   My intent was not to take input focus whilest the pointer was in my
   window.  I wanted to direct the focus to the commandWindow when a selection
   is made somewhere in the hierarchy (refer to .0).

   Once I trap once of these events, I do not understand how I attach the
   focus?   I believe this is the information that I am lacking..

   For example, when the user clicks on the title bar, I would like the
   input focus attached to the commandWindow widget.  I am using standard
   DWT widgets.

	Thanks for the help,

		Christopher

1263.7use xt$call_accept_focusREINIG::REINIGThis too shall changeMon Aug 14 1989 11:5555
    From the code in TPU that catches client messages.  The important
    call is the call to xt$call_accept_focus.
    
                                    August G. Reinig
    
        
    !
    ! If this is a DECW_WM_TAKE_FOCUS message, give input focus to one of
    ! two places, depending upon whether we are doing a read_line or not.
    !
    IF .message_type EQLU .env [decw_l_take_focus_atom]
    THEN
	BEGIN
	!
	! Save the timestamp.
	!
	env [decw_l_time_stamp] = . (event [x$r_clnt_data]);

	!
	! Check to see if we're in the middle of a READ_LINE.
	!
	IF NOT .env [decw_v_doing_readline]
	THEN
	    !
	    ! Put input focus on our main window.
	    !
	    xt$call_accept_focus (env [decw_a_main_widget],
				  event [x$r_clnt_data])
	ELSE
	    !
	    ! Put input focus on the read_line widget.  Also, set the resources
	    ! which keep the insertion point visible.
	    !
	    BEGIN
	    LOCAL
		arglist : dwt$arg_vector (3);

	    arglist [0, dwt$a_arg_name]
		= UPLIT BYTE (%ASCIZ dwt$c_ninsertion_point_visible);
	    arglist [0, dwt$l_arg_value] = 1;
	    arglist [1, dwt$a_arg_name]
		= UPLIT BYTE (%ASCIZ dwt$c_nauto_show_insert_point);
	    arglist [1, dwt$l_arg_value] = 1;
	    arglist [2, dwt$a_arg_name]
		= UPLIT BYTE (%ASCIZ dwt$c_nresize_width);
	    arglist [2, dwt$l_arg_value] = 0;
	    xt$set_values (env [decw_a_readline_widget], arglist, %REF (3));

	    xt$call_accept_focus (env [decw_a_readline_widget],
				  event [x$r_clnt_data]);
	    END;
    	RETURN;
	END;
    

1263.8LEOVAX::TREGGIARISun Aug 20 1989 10:3561
>	I have the following basic hierarchy :
>
>			top-level
>			    |
>		        main window
>			    |
>                    +-------+------------+
>                    |       |            |
>		menubar  attachedDB  commandWindow
>
>	What I would like is the following ...
>
>		(1) When I realize the top-level, focus to be assigned to
>		    the commandWindow
>
>		(2) When I puck anywhere in the top-level hierarchy, focus
>		    to be assigned to the commandWindow.
    
    What the toolkit will give you by default is the following:
    
    Not (1); this is not style guide conforming.
    
    What will happen otherwise, depends upon what the children of the
    attached dialog box are (that is, whether it has any that will
    accept focus or not).
    
    When the user clicks on the title bar, the main window widget
    will give focus to:
    
        1 - Whatever widget had it before.
        2 - If none, the work area widget (attached dialog box).
	    The attached dialog box will search its children to see
    	    if any of them will take it.
        3 - If none of the attached dialog box's children take focus, the
    	    command window widget.
    
    When the user clicks on the attached dialog box, it will attempt to
    give focus to its children as described above.
    
    When the user clicks on the command window, it will take focus.
    
    So, my guess as to the problem you are having is that the attached
    dialog box does not have any child which takes focus, so when the
    user clicks on the attached dialog box, your application does not
    get focus.
    
    If that is the problem, then you somehow need to "trap" the mouse
    click in the attached dialog box and call XtCallAcceptFocus on the
    comand window.  I'm not sure what the best way to "trap" the
    mouse click is, but here are a two ideas:
    
        o  If the attached dialog box has no gadget children, override
           its mouse button 1 down translation entry, and in the action
    	   routine call XtCallAcceptFocus.  If it has gadget children,
    	   this will break gadget processing.
    
        o  Add an Xt event handler for mouse button 1 down in the
    	   attached dialog box, and call XtCallAcceptFocus from it.
    
Leo