PDA

View Full Version : Slots and Keyboard



azizmandar
01-01-2007, 10:37 PM
I am trying to get a handle on Signals and slots but am having some trouble. I am using ClanLib 0.8.0. I can easily associate a Timer Signal with a class function but the Keyboard signals are complaining or cause a segmentation fault. All the examples I have been able to find are for 0.6.x and don't seem to work in 0.8.0

All I really need to do is bind the sig_key_down with a class function but what I would really like to be able to do is bind a specific key to a function.

Here are a few things I have tried

CL_SlotContainer myslots;
myslots.connect(CL_Keyboard::sig_key_down(),this,&ClanSimpleApp::GridOnOff);
(Compiles but gives Segmentation Fault)

and

CL_Slot keypress = CL_Keyboard::sig_key_down().connect(this,
&ClanSimpleApp::GridOnOff);
(Compiles but gives Segmentation Fault)



void ClanSimpleApp::GridOnOff(const CL_InputEvent &i)
{
//Code Here
}

sphair
01-02-2007, 12:51 PM
Does input work in the AdventureScene example? It uses signals to hook up to keyboards. You can also check out BlendFunctions or Input examples.

azizmandar
01-03-2007, 03:19 AM
Just goes to show you that the last place you look is right under your nose. I have searched the web up and down and those examples helped me fix 90% of my problems. The problem was not the way I was using the slots but the way I was calling the Display functions, the keyboard signals just made the problem show up.

Thanks for the help