[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

1357.0. "Time argument to call-accept-focus" by AIAG::SURESH (Suresh) Fri Sep 01 1989 16:59

 How should the time argument to call-accept-focus be given. From this
  notes file I found that the event data structure has the time.
 How should one get the time from the event data structure. 

 I have a set of text widgets and I want the focus to move to these widgets as
 the user finishes inputting some thing in the previous text widget. I have
 an action routine on each of the text widgets which acts a callback when the
 user enters <cr> in the text widget. At this point I want the focus to change
 to the next text widget. So what is the event from which I should take the
 time . 

 If anyone can enlighten me on the above I would really appreciate their help
 Any example code would be helpful.
Regards
Suresh

T.RTitleUserPersonal
Name
DateLines
1357.1PSW::WINALSKICareful with that VAX, EugeneFri Sep 01 1989 21:545
You should either pass the time in the event that caused you to decide you
wanted to shift focus, or you should pass the special CurrentTime value.

--PSW

1357.2RAB::DESAIJatin DesaiTue Sep 05 1989 11:20138
You may find these two routines helpful.

/* Returns time from an event data structure. */

Time
TimeOfEvent ( event )

XEvent          * event;

{
Time            local_time;

/*............................................................................*/

/* Treat null pointer specially. Return CurrentTime. */

if (event == NULL)
    {
    return(CurrentTime);
    }

/* See if this type of event has a time field associated with it. */

switch (event -> type)
    {
    case KeyPress:
        local_time = ((XKeyPressedEvent *) event) -> time;
        break;

    case KeyRelease:
        local_time = ((XKeyReleasedEvent *) event) -> time;
        break;

    case ButtonPress:
        local_time = ((XButtonPressedEvent *) event) -> time;
        break;

    case ButtonRelease:
        local_time = ((XButtonReleasedEvent *) event) -> time;
        break;

    case MotionNotify:
        local_time = ((XPointerMovedEvent *) event) -> time;
        break;

    case EnterNotify:
        local_time = ((XEnterWindowEvent *) event) -> time;
        break;

    case LeaveNotify:
        local_time = ((XLeaveWindowEvent *) event) -> time;
        break;

    case PropertyNotify:
        local_time = ((XPropertyEvent *) event) -> time;
        break;

    case SelectionClear:
        local_time = ((XSelectionClearEvent *) event) -> time;

    case SelectionClear:
        local_time = ((XSelectionClearEvent *) event) -> time;
        break;

    case SelectionRequest:
        local_time = ((XSelectionRequestEvent *) event) -> time;
        break;

    case SelectionNotify:
        local_time = ((XSelectionEvent *) event) -> time;
        break;

    case FocusIn:
    case FocusOut:
    case KeymapNotify:
    case Expose:
    case GraphicsExpose:
    case NoExpose:
    case VisibilityNotify:
    case CreateNotify:
    case DestroyNotify:
    case UnmapNotify:
    case MapNotify:
    case MapRequest:
    case ReparentNotify:
    case ConfigureNotify:
    case ConfigureRequest:
    case GravityNotify:
    case ResizeRequest:
    case CirculateNotify:
    case CirculateRequest:
    case ColormapNotify:
    case ClientMessage:
    case MappingNotify:
        local_time = CurrentTime;
        break;
    }

/* Return the time */

return(local_time);

}


/* Sets input focus to a widget */

void
SetInputFocus(widget, time )

Widget          widget;
Time            time;

{
/*............................................................................*/

/* If the widget has an accept focus routine, then call it. Otherwise,
   try setting the input focus directly. */

if (! XtCallAcceptFocus(widget, & time) )
    {
    /* Above procedure returns FALSE when there is no accept focus routine */

    /* See if this widget has an associated window before setting focus. */

    if (XtWindow (widget) != 0)
        {

        XSetInputFocus (
            XtDisplay (widget),
            XtWindow (widget),
            RevertToNone,                   /* Revert to no one if covered */
            time);
        }
    }
}