【问题标题】:Cant focus WxWidgets frame in Mac OSX compiled with SCons无法在使用 SCons 编译的 Mac OSX 中聚焦 WxWidgets 框架
【发布时间】:2010-10-31 14:32:46
【问题描述】:

我有这个可以编译的 WxWidgets 测试源代码,运行时显示一个简单的框架:

/*
 * hworld.cpp
 * Hello world sample by Robert Roebling
 */

#include "wx-2.8/wx/wx.h"

class MyApp: public wxApp
{
    virtual bool OnInit();
};

class MyFrame: public wxFrame
{
public:

     MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);

    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);

    DECLARE_EVENT_TABLE()
};

enum
{
    ID_Quit = 1,
    ID_About,
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(ID_Quit, MyFrame::OnQuit)
    EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
    MyFrame *frame = new MyFrame( _T("Hello World"), wxPoint(50,50), wxSize(450,340) );
    frame->Show(TRUE);
    SetTopWindow(frame);
    return TRUE;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
    wxMenu *menuFile = new wxMenu;

    menuFile->Append( ID_About, _T("&About...") );
    menuFile->AppendSeparator();
    menuFile->Append( ID_Quit, _T("E&xit") );

    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append( menuFile, _T("&File") );

    SetMenuBar( menuBar );

    CreateStatusBar();
    SetStatusText( _T("Welcome to wxWindows!") );
}

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    Close(TRUE);
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxMessageBox(_T("This is a wxWindows Hello world sample"),
        _T("About Hello World"), wxOK | wxICON_INFORMATION, this);
}

使用这个简单的 SCons 脚本创建:

env = Environment()
env.ParseConfig('wx-config --cxxflags --libs')

env.Program(target='wxTest/wxTest.exe',source=['src/Wxwidgets.cpp'])

问题:当我运行它时它不会集中。我唯一可以关注的是左上角的红色、黄色和绿色按钮。 我使用 Eclipse 作为我的 IDE,并在构建时将 scons 作为外部工具运行。

有没有人知道我做错了什么?如何让框架聚焦?

希望有人可以帮助我。

【问题讨论】:

  • 请注意,您还应该删除 id 枚举,并使用在 wxMac 中专门处理的预定义 wxID_EXIT 和 wxID_ABOUT id,因为这些命令的菜单项将移动到适当的平台原生应用程序菜单中的位置。请参阅wiki.wxwidgets.org/WxMac_Issues 了解更多信息。

标签: c++ eclipse macos wxwidgets scons


【解决方案1】:

我假设您启动创建的原始可执行文件?这在 Mac OS X 上不起作用,请参阅 My app can't be brought to the front!

您必须为您的应用程序创建一个应用程序包才能在 Mac OS X 上正常工作。我对 SCons 一无所知,但也许 wiki 确实有帮助?

【讨论】:

  • 啊,我不知道我需要一个捆绑包。也许我只需要深入研究如何为我的程序制作它:)谢谢你的链接!!
猜你喜欢
  • 1970-01-01
  • 2018-09-15
  • 2020-07-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-26
  • 2012-06-30
相关资源
最近更新 更多