1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#include "ui/ui.h"
#include "ui/uidefs.h"
void UI_KEYTRAP::create(UI_WINDOW *wnd, int key, void (*_user_function)(void) )
{
base_create( wnd, UI_KIND_BUTTON, 0, 0, 0, 0 );
pressed_down = 0;
set_hotkey(key);
set_callback(_user_function);
parent = this; // Ugly. This keeps KEYTRAPS from getting keyboard control.
}
void UI_KEYTRAP::draw()
{
}
void UI_KEYTRAP::process(int /*focus*/)
{
pressed_down = 0;
if (disabled_flag) {
return;
}
if (my_wnd->keypress == hotkey) {
pressed_down = 1;
my_wnd->last_keypress = 0;
}
if (pressed_down && user_function) {
user_function();
}
}
int UI_KEYTRAP::pressed()
{
return pressed_down;
}
|