如何在没有事件的情况下直接在wxWidgets中调用事件处理程序方法 [英] How to call an event handler method directly in wxWidgets without an event

查看:150
本文介绍了如何在没有事件的情况下直接在wxWidgets中调用事件处理程序方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个wxWidgets窗体(使用wxFormBuilder),并且具有按钮/菜单/工具栏,所有这些都生成事件来调用各种方法(例如,所有这些都很完美)。这些事件方法中的每一个都是这样定义的:

  void cLoggingFrame :: me_InsertCommentText(wxCommandEvent& event); 

现在,我想要做的是重用这些方法中的一些方法直接打电话给他们我不想生成要处理的事件,我希望方法在调用时运行。例如,我想做这样的事情(这不行)

  me_InsertCommentText(NULL); 

现在,我明白我可以让每个事件方法调用另一种方法(无参数)从其他位置调用,但在其他语言中,我已经能够绕过参数需求为NULL。



有没有办法这样做wxWidgets而不需要传递给事件处理程序的方法只是普通的c ++方法,你必须通过正确的参数
这样的事情将会伎俩

  me_InsertCommentText(wxCommandEvent()); 


Visual Studio 2008 C++ Windows Xp SP3

I have created a wxWidgets form (using wxFormBuilder) and have buttons/menus/toolbars all generating events to call various methods (all this works perfectly). Each of these event methods is defined like this:

void cLoggingFrame::me_InsertCommentText(wxCommandEvent& event);

Now, what I want to be able to do is 're-use' some of these methods by calling them directly. I don't want to generate an event to be handled, I want the method to run when I call it. For example, I want to do something like this (this doesn't work)

me_InsertCommentText(NULL);

Now, I understand that I could have each event method just call another method (without parameters) that could be called from other locations, but in other languages I've been able to bypass the parameter requirement with NULL.

Is there any way to do this with wxWidgets without the need for an additional method?

解决方案

Methods passed to Event-Handlers are just ordinary c++ methods, you have to pass correct parametes something like this will do the trick

me_InsertCommentText(wxCommandEvent());

这篇关于如何在没有事件的情况下直接在wxWidgets中调用事件处理程序方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆