gpt4 book ai didi

c++ - 3.1.3 上的 wxWidgets mac 剪贴板坏了?

转载 作者:行者123 更新时间:2023-11-28 04:03:07 26 4
gpt4 key购买 nike

我不确定我是否在做一些极其愚蠢的事情,但我对剪贴板的调用从 3.1.3 开始就停止工作了。我进入代码,它都在较低级别工作(wxClipboard::AddData 返回 true)。这在 3.1.2 下工作,我使用以下配置在 macOS 10.12.6 Sierra 上构建:

configure --disable-shared --enable-unicode --prefix="$(pwd)" --enable-ipc --enable-base64 --enable-exceptions --enable-fontenum --enable-fs_archive --enable-stdpaths --enable-sysoptions --enable-threads --enable-url --enable-aui  --enable-graphics_ctx  --enable-printarch --enable-timer --enable-ribbon --enable-webview --enable-display --enable-splash --enable-snglinst --enable-printfposparam --with-opengl --with-osx_cocoa --with-expat=builtin --with-cxx=11 --enable-cxx11 --enable-stl --enable-std_iostreams --enable-std_string --enable-ftp --enable-http --enable-fileproto --enable-sockets --enable-ipv6 --enable-dataobj --enable-ipc --enable-any --enable-arcstream --enable-backtrace --enable-cmdline --enable-datetime --enable-debugreport --enable-dynamicloader --enable-exceptions --enable-ffile --enable-file --enable-filehistory --enable-filesystem --enable-fontmap --enable-fs_inet --enable-fs_zip --enable-fsvolume --enable-fswatcher --enable-geometry --enable-sound --enable-stopwatch --enable-streams --enable-tarstream --enable-textbuf --enable-textfile --enable-variant --enable-zipstream --enable-protocol --enable-protocol-http --enable-protocol-ftp --enable-protocol-file --enable-html --enable-htmlhelp --enable-propgrid --enable-svg --enable-clipboard --enable-dnd --enable-accel --with-osx_cocoa  --disable-debug_flag --with-libpng=builtin --with-libjpeg=builtin --with-zlib=builtin

我知道基础 SDK 已经从以前的(10.4?)移动到(10.9),但我没有明确指定它,所以我将使用 3.1.3 的默认值。

对于我使用以下配置选项构建的同一系统下的 wxWidgets 3.1.3:

configure --disable-shared --enable-unicode --prefix="$(pwd)" --enable-stc --enable-ipc --enable-base64 --enable-exceptions --enable-fontenum --enable-fs_archive --enable-stdpaths --enable-sysoptions --enable-threads --enable-url --enable-aui  --enable-graphics_ctx  --enable-printarch --enable-timer --enable-ribbon --enable-webview --enable-display --enable-splash --enable-snglinst --enable-printfposparam --with-opengl --with-osx_cocoa --with-expat=builtin --with-cxx=11 --enable-cxx11 --enable-stl --enable-std_iostreams --enable-std_string --enable-ftp --enable-http --enable-fileproto --enable-sockets --enable-ipv6 --enable-dataobj --enable-ipc --enable-any --enable-arcstream --enable-backtrace --enable-cmdline --enable-datetime --enable-debugreport --enable-dynamicloader --enable-exceptions --enable-ffile --enable-file --enable-filehistory --enable-filesystem --enable-fontmap --enable-fs_inet --enable-fs_zip --enable-fsvolume --enable-fswatcher --enable-geometry --enable-sound --enable-stopwatch --enable-streams --enable-tarstream --enable-textbuf --enable-textfile --enable-variant --enable-zipstream --enable-protocol --enable-protocol-http --enable-protocol-ftp --enable-protocol-file --enable-html --enable-htmlhelp --enable-propgrid --enable-svg --enable-clipboard --enable-dnd --enable-accel --with-osx_cocoa  --disable-debug_flag --with-libpng=builtin --with-libjpeg=builtin --with-zlib=builtin --with-libtiff=builtin

我已经编写了一个示例测试应用程序来对此进行测试,但剪贴板似乎已失效。如果我使用剪贴板示例,粘贴按钮将被禁用。

这是一个测试应用程序:

#include <wx/wx.h>
#include <wx/app.h>
#include <wx/clipbrd.h>

class MainFrame : public wxFrame
{
protected:
wxStaticText* label;
public:
MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL )
: wxFrame(parent, id, title, pos, size, style)
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );
label = new wxStaticText( this, wxID_ANY, wxT("<pasted text should go here>"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT|wxST_NO_AUTORESIZE );
label->Wrap( -1 );
bSizer1->Add( label, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
this->SetSizer( bSizer1 );
this->Layout();
this->Centre( wxBOTH );

if (wxTheClipboard->Open())
{
wxTheClipboard->SetData(new wxTextDataObject("Hello this is pasted text"));
wxTheClipboard->Close();
}
if (wxTheClipboard->Open())
{
if (wxTheClipboard->IsSupported( wxDF_TEXT ))
{
wxTextDataObject data;
wxTheClipboard->GetData(data);
label->SetLabel(data.GetText());
}
wxTheClipboard->Close();
}
}
virtual ~MainFrame() { }
};

class demoApp: public wxApp
{
MainFrame *frame = nullptr;
public:
demoApp();
virtual ~demoApp() { }
virtual bool OnInit() override;
};

IMPLEMENT_APP(demoApp)
//#include <ApplicationServices/ApplicationServices.h>
demoApp::demoApp()
{
//ProcessSerialNumber PSN;
//GetCurrentProcess(&PSN);
//TransformProcessType(&PSN,kProcessTransformToForegroundApplication);
}
bool demoApp::OnInit()
{
frame = new MainFrame(nullptr);
frame->Show();
SetTopWindow(frame);
SetExitOnFrameDelete(true);
return true;
}

你可以用类似的东西来构建它

g++ clipboard.cpp -o clipboard -std=gnu++11 -I/DeveloperLibs/wxWidgets-3.1.3/build-debug/lib/wx/include/osx_cocoa-unicode-static-3.1/ -I/DeveloperLibs/wxWidgets-3.1.3/include -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ -D_DEBUG=1-stdlib=libc++ -L/DeveloperLibs/wxWidgets-3.1.3/build-debug/lib/ -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -lwx_baseu-3.1 -lwx_osx_cocoau_adv-3.1 -lwx_osx_cocoau_core-3.1 -liconv -lz -headerpad_max_install_names -lwxregexu-3.1 -lwx_osx_cocoau_qa-3.1 -framework Quartz -lwx_baseu_xml-3.1 -lwxjpeg-3.1 -lwxpng-3.1 -lwxzlib-3.1 -lwxexpat-3.1 -lwxtiff-3.1 -llzma

我完全看不出有什么问题??我应该注意到,同一个应用程序无法在 Mojave 下运行(使用来自 Sierra 系统的二进制文件,甚至使用我的 Mojave 系统上的 wxWidgets 在 Mojave 下构建的二进制文件)。

最佳答案

是的,不幸的是,复制到剪贴板在 3.1.3 发布前不久被破坏了。它很快就在 this commit 中修复了你应该能够在本地挑选——或者你可以只更新到最新的主控。

关于c++ - 3.1.3 上的 wxWidgets mac 剪贴板坏了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59180068/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com