Re: Once again with SCANF, but now I'm about to solve it!!!

Search this archive.

From: Martijn van Oosterhout (kleptog@cupid.suninternet.com)
Date: Tue 05 Sep 2000 - 17:01:52 IDT


Nicolas Raitman wrote:
> 
[-- snip code --]
> 
> /* the following cycle is to get the numbers, store it in a char array and
> then i will convert it to a float. The problem here is that i want the
> characters to be printed while the user is typing. I tried to add a
> gl_printf(...) i the middle of the cycle, but i come up with some problems.
> The first one is that i have to specify a position, and since this will be a
> routine it can be called when the cursor is anywhere on the the screen: it
> can be at x = 200, or x = 400, so what i want to do is to place the cursos
> 10 position to the right where it was the last time before entering the
> cycle.

Ok, just a couple of points:

- In graphics mode, there is *no* cursor position. Any position that
you want you have to work out yourself.

- So, what you do is decide where you want the text to appear on the
screen. So make an x and y coordinate for that. Then whenever you read
a key, display it at that x and y and add 10 pixels to the x.

- You'll have to handle some keys specially, most notably the enter key
and the backspace key.

- If you want to check the actual input, add code for that
appropriately.

At least, thats how it worked last time I worte this type of code 
(a while ago now).

Hope this helps,
-- 
Martijn van Oosterhout <kleptog@cupid.suninternet.com>
http://cupid.suninternet.com/~kleptog/


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST