|
From: | Fu Steve X |
Subject: | Set focus outside of traverelCDK in CDK |
Date: | Fri, 23 Dec 2005 08:36:11 -0500 |
I was trying to get a RESET feature to work. That is, emptying the input field and setting the focus to the first widget on the screen. I changed the switchFocus function in CDK to non-static so it can be called from user code. But the switchFocus has no effect in my code. Is that because the focusing was controlled by traverseCDKScreen?
Appended is a hello-world type program that illustrates my attempt.
Thanks.
Steve
/********************* cut here ***********************/
#include <cdk.h>
WINDOW *cursesWin = 0;
CDKSCREEN *cdkscreen = 0;
CDKENTRY *entry = 0;
CDKBUTTON *btn1 = 0;
CDKBUTTON *btn2 = 0;
CDKLABEL *lbl = 0;
static int resetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)
{
CDKOBJS * currObj = getCDKFocusCurrent(cdkscreen);
setCDKEntryValue(entry, "");
switchFocus (ObjOf(entry), currObj); /* was static in CDK */
refreshCDKScreen(cdkscreen);
return (TRUE);
}
/*
* This demonstrates the Cdk entry field widget.
*/
int main(int argc, char **argv)
{
/* Declare local variables. */
char *title = "<C>Enter \n<C>Something.";
char *label = "Value: ";
char *info, temp[256];
char *msg[1] = { "</U/5>F7<!U!5> - RESET"};
CDK_PARAMS params;
CDKparseParams(argc, argv, ¶ms, CDK_MIN_PARAMS);
/* Set up CDK. */
cursesWin = initscr();
cdkscreen = initCDKScreen (cursesWin);
/* Create the entry field widget. */
entry = newCDKEntry (cdkscreen,
CDKparamValue(¶ms, 'X', CENTER),
CDKparamValue(¶ms, 'Y', 1),
title, label, A_NORMAL, '.', vMIXED,
40, 0, 256,
CDKparamValue(¶ms, 'N', TRUE),
CDKparamValue(¶ms, 'S', FALSE));
btn1 = newCDKButton (cdkscreen,
CDKparamValue(¶ms, 'X', CENTER),
CDKparamValue(¶ms, 'Y', 7),
"Button 1", NULL,
TRUE, FALSE);
btn2 = newCDKButton (cdkscreen,
CDKparamValue(¶ms, 'X', CENTER),
CDKparamValue(¶ms, 'Y', 11),
"Button 2", NULL,
TRUE, FALSE);
lbl = newCDKLabel (cdkscreen,
CDKparamValue(¶ms, 'X', CENTER),
CDKparamValue(¶ms, 'Y', 16),
msg, 1,
CDKparamValue(¶ms, 'N', FALSE),
CDKparamValue(¶ms, 'S', FALSE));
bindCDKObject (vENTRY, entry, KEY_F(7), resetCB, NULL);
bindCDKObject (vBUTTON, btn1, KEY_F(7), resetCB, NULL);
bindCDKObject (vBUTTON, btn2, KEY_F(7), resetCB, NULL);
refreshCDKScreen(cdkscreen);
traverseCDKScreen(cdkscreen);
/* Clean up and exit. */
destroyCDKScreen (cdkscreen);
endCDK();
exit (EXIT_SUCCESS);
}
[Prev in Thread] | Current Thread | [Next in Thread] |