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