Here is my code:
public void Initialize()
{
//something here
onKeyDown();
}
static void onKeyDown(KeyEventArgs e)
{
if (e.Key == Keys.H)
{
//do stuff
}
}
and I get this error: There is no argument given that corresponds to the required formal parameter 'e' of 'Main.onKeyDown(KeyEventArgs)'.
EDIT: Working With RAGE Plugin Hook, a library for gta v mod development.
CodePudding user response:
I'm not really sure why you shouldn't do it, I'll let smarter people describe it.
Anyway, there's a way to call an event this way:
public void Initialize()
{
onKeyDown((KeyEventArgs)System.EventArgs.Empty)
}
I would comment it but not enough reputation :(
CodePudding user response:
Cannot comment yet so posting as response.
You need to share what you are trying to do here. Why would you want to simulate a keypress? You could perhaps do something like this:
public void Initialize()
{
//something here
//onKeyDown();
DoStuff();
}
static void onKeyDown(KeyEventArgs e)
{
if (e.Key == Keys.H)
{
DoStuff();
}
}
static void DoStuff(){
// DoStuff
}
To me it appears that you are trying to explicitly call an even handler which is not the purpose of event handlers. They are designed to be executed on if a certain user action or automated application action takes place.