Is there any function in wxWidgets framework, say, click(), whose function is to emulate a left-click mouse?
If you're just talking about emulating a click on another button in your wxWidgets app, I've tried this before:
Create a fake wxEvent of the right type, tell the event what object to care about using SetEventObject(), and tell a parent wxWindow in the hierarchy to ProcessEvent(myNewEvent). You might want to use wxGetTopLevelParent() to get the topmost frame/dialog
If you are talking about emulating a click in another, non-wxWidgets process, it's possible you could use the OS's accessibility APIs to do this. wxAccessibility should be able to help with this on Windows -- for other OSes, last I heard (granted, a few years ago), you'll have to use the native OS functions.
No, there is no function like this. If you really need to do it, e.g. because you want to perform some action in another application you need to write platform-specific code yourself (e.g. use SendInput() under Windows).
If you want to use this to execute some code in your own application though, there is a much better solution: instead of doing unsupported, fragile and ugly
void MyClass::OnLeftUp(wxMouseEvent& event)
{
... do something with click at event.GetPosition() ...
}
void MyOtherFunction()
{
wxMouseEvent event(...);
... initialization not shown because there is no right way to do it anyhow ...
myObject->ProcessEvent(event);
}
just refactor your code to do it like this instead:
void MyClass::OnLeftUp(wxMouseEvent& event)
{
HandleClick(event.GetPosition());
}
void MyClass::HandleClick(const wxPoint& pos)
{
... do something with click at pos ...
}
void MyOtherFunction()
{
myObject->HandleClick(position);
}