Re: [VDKBuilder]Handling keypress events in a form
Brought to you by:
gertwin
|
From: Mario M. <mm...@gu...> - 2001-04-30 22:00:11
|
Michael Wagner wrote:
>
> Hi!
>
> Sorry for the newbie question, but how can I use VDK to handle a key
> press in a form? I can't seem to follow the documentation as far as this
> is concerned. If someone could point me to the relevant classes or
> (better yet) example code, I'd appreciate it.
>
> Thanks!
>
> -Mike
>
tim lorenz answer cant completely work since you cannot have "this" as
receiver and because static event tables are incomplete. Instead using
extended signal system works as tim said.
Here a code snippet that uses run-time event tables that are the
preferred way:
/*
main form setup
*/
void
PippoForm::Setup(void)
{
GUISetup();
// connect "this" (aka the form) to key-press event
EventConnect("key_press_event",&PippoForm::OnKeyPress);
}
/*
more info about key event into:
gdk/gdktypes.h
gdk/gdkkeysims.h
*/
bool
PippoForm::OnKeyPress(VDKObject* sender, GdkEvent* e)
{
GdkEventKey* event = (GdkEventKey*) e;
printf("\nOnkeyPress:\nkey:%u - state:%d",event->keyval,event->state);
fflush(stdout);
return true;
}
--
Mario Motta
AI Research Group - Rimini
http://vdkbuilder.sourceforge.net
|