<- previous    index    next ->

Lecture 6, Getting user input

In GUI applications, the code to get user input is much more
complex than the code for a command line program.

Much user input is via the mouse, button press or motion.
Some user input is from the keyboard.

Mouse button press input in examples:
w2.c  X Windows

w2gl.c  OpenGL

W2frame.java  Java

Getting input data, text, into a graphical user interface program
is much more difficult. The input of numbers is accomplished by
inputting a character string and converting the character string
to a number inside the program.

The X Windows Motif program w5a has one pull-down menu on the menu bar,
"Set Values". On the pull-down there are five menu items:
  "Number"
  "View Angle"
  "Name"
  "Apply"
  "Quit"

The selecting one of the first three causes a popup dialog box to
appear. The dialog box is where the user enters the data.








The source code is:
w5a.c  X Windows
w5.h 

In OpenGL and GLUT I wrote my own data entry in fixed windows.
These could be made into separate windows and could be
selected by a menu.
test_text_in.c  OpenGL
demo_text_in.c
text_in.h
text_in.c

Now, add a popup dialog window for user data entry.
w5gl.c


The Java implementation is the shortest.
Similar "toolkit" classes should be available for
Microsoft C++ and C#.

W5frame.java  Java








Another simple screen input/output Java program is Fahrenheit.java
 


When you can input text, a character string, then you can
use your programming language to open and read and write files.
You can get numeric data when needed but do not use this as
a substitute for mouse input for numeric data,
with possible use a grid for accuracy.

    <- previous    index    next ->

Other links

Go to top