bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Syncronization between highlight and cursor in new CDK


From: Fu Steve X
Subject: Syncronization between highlight and cursor in new CDK
Date: Fri, 6 Jan 2006 08:49:48 -0500

I know the synchronization between highlight and cursor position are much better in the new version. But there are still some subtleties. Please just look at the resetCB function in the test program below.

Tabbing to Button 1 and press F7 to reset. There are different behaviors depending on the order of two lines of code.

If refreshCDKScreen is called after setCDKFocusFirst, then the cursor is put at the last position (lower right-hand corner) of the screen although the focus does move to the entry widget. If the setCDKFocusFirst is called after refreshCDKScreen, both the cursor and the focus are put at the entry widget correctly, but Button 1 is still left highlighted.

       
Thanks.


Steve Fu

------------------------------------ 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  escCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData GCC_UNUSED, chtype key GCC_UNUSED)

{
        endCDK();
   exit(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, "");   

        /* Neither order of the two lines below gives correct behavior */
        setCDKFocusFirst(cdkscreen);
        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, &params, CDK_MIN_PARAMS);

   /* Set up CDK. */
   cursesWin = initscr();
   cdkscreen = initCDKScreen (cursesWin);

   /* Create the entry field widget. */
   entry = newCDKEntry (cdkscreen,
                            CDKparamValue(&params, 'X', CENTER),
                            CDKparamValue(&params, 'Y', 1),
                            title, label, A_NORMAL, '.', vMIXED,
                            40, 0, 256,
                            CDKparamValue(&params, 'N', TRUE),
                            CDKparamValue(&params, 'S', FALSE));

        btn1 = newCDKButton (cdkscreen,
                                CDKparamValue(&params, 'X', CENTER),
             CDKparamValue(&params, 'Y', 7),
                 "Button 1", NULL,
                 TRUE, FALSE);

        btn2 = newCDKButton (cdkscreen,
                                CDKparamValue(&params, 'X', CENTER),
             CDKparamValue(&params, 'Y', 11),
                 "Button 2", NULL,
                 TRUE, FALSE);

        lbl = newCDKLabel (cdkscreen,
             CDKparamValue(&params, 'X', CENTER),
             CDKparamValue(&params, 'Y', 16),
             msg, 1,
             CDKparamValue(&params, 'N', FALSE),
             CDKparamValue(&params, 'S', FALSE));

   bindCDKObject (vENTRY, entry, KEY_F(7), resetCB, NULL);
   bindCDKObject (vENTRY, entry, KEY_ESC, escCB, NULL);

   bindCDKObject (vBUTTON, btn1, KEY_F(7), resetCB, NULL);
   bindCDKObject (vBUTTON, btn1, KEY_ESC, resetCB, NULL);

   bindCDKObject (vBUTTON, btn2, KEY_F(7), resetCB, NULL);
   bindCDKObject (vBUTTON, btn2, KEY_ESC, resetCB, NULL);

        refreshCDKScreen(cdkscreen);

        traverseCDKScreen(cdkscreen);

   /* Clean up and exit. */
   destroyCDKScreen (cdkscreen);
   endCDK();
   exit (EXIT_SUCCESS);
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]