uEZ GUI Start Here Guide
UEZGUI-1788-56VI
Rev. 1.11 Aug 31, 2016
Page 19
E.
Adding Callback Functionality
Now that the second screen has been created, return to HomeScreen.c and add a
callback function to the previously created button. Once this callback function is
created, the button will switch to the newly created second window when it is pressed.
1.
Add the name of the callback function into the first widget definition matrix. (the
“Temperature” button) You can choose any name to give the callback function. In
this example we used
(TBool (*)(WM_MESSAGE *, TInt32, TInt32)) IHandleSecondScreen to make the
function name easily understandable.
2.
Declare the callback function’s prototype between the “Global Data” and “Local
Data” sections of the HomeScreen.c file. In addition add the “G_WhichWindow”
variable in the “Global Data” section.
3.
Create the callback function below the “Local Data” section. This function takes a
message from the event handler and switches windows when the button is pressed.
/*---------------------------------------------------------------------------*
* Global Data:
*--------------------------------------------------------------------------*/
static
TBool G_Active
=
EFalse
;
// Active Flag, tell the dialog when it
receives messages that the screen is in the foreground
TInt32 G_WhichWindow;
// Variable to hold the ID of the active window
/*-------------------------------------------------------------------------*
* Function Prototypes:
*-------------------------------------------------------------------------*/
static
TBool IHandleSecondScreen
(
WM_MESSAGE
*
pMsg
,
int
aNCode
,
int
aID
);
/*---------------------------------------------------------------------------*
* Local Data:
*--------------------------------------------------------------------------*/