Hi,
i want to take textual input in my window, rendered using glut. i have created a rectangle depicting a text box and have set it using glRasterPos2i(), so that the text gets entered in it. i have used glutBitmapCharacter(GLUT_BITMAP_9_BY_15,k); where k is the character according to the keypress. this is all working fine… my trouble is i am not able to handle the backspace… i am able to go back one character but the character already present there is not “erased”, the new keypress is written on top of the old one…
how can i erase the previous character???
my keyboard function is as follows:
void keyboard(unsigned char k,int x,int y)
{
glColor3f(0.0,0.0,0.0);
glRasterPos2f(rx,2.27);
if((inc==0)&&((int)k==13))
{
glutSetWindow(id1);
glutPostRedisplay();
}
else if(int(k)!=13)// keypressed is not the return key
{
if(int(k)==8)//key press is backspace
{
inc--;
rx-=0.1;
glColor3f(1.0,1.0,1.0);
glutBitmapCharacter(GLUT_BITMAP_9_BY_15,s[inc]);
glColor3f(0.0,0.0,0.0);
}
else
{
s[inc++]=k;
glutBitmapCharacter(GLUT_BITMAP_9_BY_15,k);
rx+=0.1;
glutSwapBuffers();
glutSwapBuffers();
}
}
else
{
s[inc]='\0';
if(!recogniz())
{
glutSetWindow(id);
glutPostRedisplay();
}
glutSetWindow(id1);
glutPostRedisplay();
rx=-2.5;
inc=0;
}
}
[This message has been edited by Richa (edited 10-01-2002).]
[This message has been edited by Richa (edited 10-01-2002).]