Article # 419, added by Geoworks, historical record
| first | previous | index | next | last |

How to make a subclassed UI object grab the focus.



Q. I have a bunch of custom objects inside a GenInteraction. The problem
   is I cannot select them via the normal focus navigation methods
   (e.g. tab key, cursor keys). The focus skips straight over my custom
   objects and only highlights on the system UI objects.

A. Intercept MSG_SPEC_NAVIGATION_QUERY for your subclassed object and
   do this:

/*********************************************************************
 *              MSG_SPEC_NAVIGATION_QUERY
 *********************************************************************
 * SYNOPSIS:     We've been asked by the system whether we are capable
 *               of receiving the focus or not.
 * PARAMETERS:   NavigationQueryParams * retValue
 *               optr                    queryOrigin
 *               NavigationFlags         navFlags
 * RETURNS:      Boolean - TRUE if this is the object to get the focus
 * SIDE EFFECTS: none
 * STRATEGY:     Prepare the parameters for MSG_SPEC_NAVIATE_COMMON
 *               (checking to make sure we are a usable object) and
 *               then call the common navigation method to do the
 *               real work. Stuff the return values into retVal and
 *               return the true/false flag to the caller.
 ********************************************************************/
@method SomeSubClass, MSG_SPEC_NAVIGATION_QUERY
{
      /*
       * params - spec navigation parameters
       * reply  - the reply we will return
       */
    NavigateCommonParams params;
    Boolean              reply;

    params.NCP_object = queryOrigin;
    params.NCP_navFlags = navFlags;
    if ( @call self::MSG_GEN_GET_USABLE() ) {
        params.NCP_navCommonFlags = NCF_IS_FOCUSABLE;
    }
    else {
        params.NCP_navCommonFlags = 0;
    }
    params.NCP_genPart = OptrToChunk( oself );
    reply = @call self::MSG_SPEC_NAVIGATE_COMMON( ¶ms );
    retValue->NQP_navFlags = params.NCP_navFlags;
    retValue->NQP_backtrackFlag = params.NCP_backtrackFlag;
    retValue->NQP_nextObject = params.NCP_object;
    return( reply );
} /* MSG_SPEC_NAVIGATION_QUERY */