]> icculus.org git repositories - taylor/freespace2.git/blob - src/ui/keytrap.cpp
The Great Newline Fix
[taylor/freespace2.git] / src / ui / keytrap.cpp
1 /*
2  * $Logfile: /Freespace2/code/UI/KEYTRAP.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Routines for gadgets that trap keypresses.
8  *
9  * $Log$
10  * Revision 1.2  2002/05/07 03:16:53  theoddone33
11  * The Great Newline Fix
12  *
13  * Revision 1.1.1.1  2002/05/03 03:28:11  root
14  * Initial import.
15  *
16  * 
17  * 2     10/07/98 10:54a Dave
18  * Initial checkin.
19  * 
20  * 1     10/07/98 10:51a Dave
21  * 
22  * 2     1/14/98 6:43p Hoffoss
23  * Massive changes to UI code.  A lot cleaner and better now.  Did all
24  * this to get the new UI_DOT_SLIDER to work properly, which the old code
25  * wasn't flexible enough to handle.
26  * 
27  * 1     11/14/96 6:55p John
28  *
29  * $NoKeywords: $
30  */
31
32 #include "uidefs.h"
33 #include "ui.h"
34
35
36 void UI_KEYTRAP::create(UI_WINDOW *wnd, int key, void (*_user_function)(void) )
37 {
38         base_create( wnd, UI_KIND_BUTTON, 0, 0, 0, 0 );
39
40         pressed_down = 0;
41         set_hotkey(key);
42         set_callback(_user_function);
43
44         parent = this;          // Ugly.  This keeps KEYTRAPS from getting keyboard control.
45 };
46
47 void UI_KEYTRAP::draw()
48 {
49 }
50
51 void UI_KEYTRAP::process(int focus)
52 {
53         pressed_down = 0;
54
55         if (disabled_flag) {
56                 return;
57         }
58
59         if (my_wnd->keypress == hotkey) {
60                 pressed_down = 1;
61                 my_wnd->last_keypress = 0;
62         }
63
64         if (pressed_down && user_function)      {
65                 user_function();
66         }
67 }
68
69 int UI_KEYTRAP::pressed()
70 {
71         return pressed_down;
72 }
73