GOLMsgCallback Function

Microchip Graphics Library

Microchip Graphics Library
GOLMsgCallback Function
C
WORD GOLMsgCallback(
    WORD objMsg, 
    OBJ_HEADER * pObj, 
    GOL_MSG * pMsg
);
Overview

The user MUST implement this function. GOLMsg() calls this function when a valid message for an object in the active list is received. User action for the message should be implemented here. If this function returns non-zero, the message for the object will be processed by default. If zero is returned, GOL will not perform any action.

Input Parameters
Input Parameters 
Description 
WORD objMsg 
Translated message for the object or the action ID response from the object. 
OBJ_HEADER * pObj 
Pointer to the object that processed the message. 
GOL_MSG * pMsg 
Pointer to the GOL message from user. 
Returns

Return a non-zero if the message will be processed by default. If a zero is returned, the message will not be processed by GOL.

Preconditions

none

Side Effects

none

Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG *pMsg){
    static char focusSwitch = 1;

    switch(GetObjID(pObj)){
        case ID_BUTTON1:
            // Change text and focus state
            if(objMsg == BTN_MSG_RELEASED){
                focusSwitch ^= 1;
                if(focusSwitch){
                    BtnSetText((BUTTON*)pObj, "Focused");
                    SetState(pObj,BTN_FOCUSED);
                }else{
                    BtnSetText((BUTTON*)pObj, "Unfocused");
                    ClrState(pObj,BTN_FOCUSED);
                }
            }
            // Process by default
            return 1;
        case ID_BUTTON2:
            // Change text
            if(objMsg == BTN_MSG_PRESSED){
                BtnSetText((BUTTON*)pObj, "Pressed");
            }
            if(objMsg == BTN_MSG_RELEASED){
                BtnSetText((BUTTON*)pObj, "Released");
            }
            // Process by default
            return 1;
        case ID_BUTTON3:
            // Change face picture
            if(objMsg == BTN_MSG_PRESSED){
                BtnSetBitmap(pObj,arrowLeft);
            }
            if(objMsg == BTN_MSG_RELEASED){
                BtnSetBitmap(pObj,(char*)arrowRight);
            }
            // Process by default
            return 1;
        case ID_BUTTON_NEXT:
            if(objMsg == BTN_MSG_RELEASED){
                screenState = CREATE_CHECKBOXES;
            }
            // Process by default
            return 1;
        case ID_BUTTON_BACK:
            return 1;
        default:
            return 1;
    }
}               
Microchip Graphics Library Version 3.06.02 - October 15, 2012
Copyright © 2012 Microchip Technology, Inc.  All rights reserved