wxFileDialog 文件名文本框显示为已剪裁

wxFileDialog filename textbox appears as clipped

我使用以下代码显示“打开文件”对话框:

wxFileDialog fileDialog(
    this,
    wxEmptyString,
    "E:\Testfiles",
    "SOME_TEST_FILE_WITH_LONG_NAME.txt",
    "TXT files (*.txt)|*.txt",
    wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR);
if (fileDialog.ShowModal() == wxID_OK)
{
    // do something with the file
}

请注意,我将默认文件名设置为一个长字符串(大约 10 个或更多字符)。
显示文件对话框时,文件名 看起来 被截断了。

但经过检查,它并没有真正剪裁。
更像是文本的起点太靠左了。
当您将光标放在文本框上并向左滚动时,您将获得完整的文件名。

此外,当您切换到另一个 window 然后 return 文件对话框时,它会自行更正并显示完整的文件名。

这并没有真正影响文件对话框的功能。
这更像是一个美学问题。

但是如果有这种行为的原因或者是否有解决方案,我想知道。

谢谢!

我正在使用:


更新(2017/03/20)

我在 wxTrac 为这个错误开了一张票。
你可以在这里查看: http://trac.wxwidgets.org/ticket/17824.

这看起来像是 wxWidgets 中的一个错误,请尝试在 dialogs sample by making minimal changes to the wxFileDialog call which is already present there and open a ticket on wxTrac 中重现它,并使用允许查看问题的补丁,以便有人可以调试它。

作为临时解决方法(虽然 official resolution from wxWidgets 尚不可用),在正确构建文件对话框后调用 CenterOnParent() "scrolls" 文件名,这样它就不会显示为"clipped".

wxFileDialog fileDialog(
    this,
    wxEmptyString,
    "E:\Testfiles",
    "SOME_TEST_FILE_WITH_LONG_NAME.txt",
    "TXT files (*.txt)|*.txt",
    wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR);

// fixes the clipped filename
fileDialog.CenterOnParent();

if (fileDialog.ShowModal() == wxID_OK)
{
    // do something with the file
}