-
Notifications
You must be signed in to change notification settings - Fork 329
-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hidden widgets (textbox, etc) still show carets & pressing tab key switches focus on invisible(hidden) widgets. #62
Comments
Hi, thank you for reporting this issue, a fix has been checked into the hotfix branch. Look forward to your feedback. |
Hi Jinhao. I found a problem with the fix. In Please use below code to reproduce the problem. #include <nana/gui.hpp>
#include <nana/gui/widgets/textbox.hpp>
using namespace nana;
#if 1
#include <Windows.h>
int WINAPI WinMain(
HINSTANCE hInstance, // 現在のインスタンスのハンドル
HINSTANCE hPrevInstance, // 以前のインスタンスのハンドル
LPSTR lpCmdLine, // コマンドライン
int nCmdShow // 表示状態
)
#else
int main()
#endif
{
using namespace nana;
form fm(API::make_center(500, 300));
fm.caption(L"tabstop test");
textbox txt(fm, rectangle{50, 50, 100, 30});
txt.multi_lines(false);
txt.caption(L"aaaa");
textbox txt2(fm, rectangle(50, 90, 200, 200));
txt2.caption(L"aaaa\nbbbb\ncccc\n");
API::eat_tabstop(txt, false);
API::eat_tabstop(txt2, false);
txt.hide();
txt2.hide();
fm.show();
exec();
}
|
Here is a workaround for infinite loop in window_manager::tabstop method. window_manager::core_window_t* get_tabstop(window_manager::core_window_t* wd, bool forward)
{
auto & tabs = wd->root_widget->other.attribute.root->tabstop;
if (tabs.size())
{
bool visible = false;
for (auto& i : tabs) {
if (i->visible) {
visible = true;
break;
}
}
if (!visible) {
return nullptr;
}
if (forward) //
|
Thank you for your helpful feedback. I updated the fix. |
Thank you for the fix. Please check below program Parent widget hidden case. #include <nana/gui.hpp>
#include <nana/gui/widgets/textbox.hpp>
#include <nana/gui/widgets/panel.hpp>
using namespace nana;
int main()
{
using namespace nana;
form fm(API::make_center(500, 300));
fm.caption(L"tabstop test");
panel<true> panel(fm, rectangle(fm.size()));
textbox txt(panel, rectangle{50, 50, 100, 30});
txt.multi_lines(false);
txt.caption(L"aaaa");
textbox txt2(panel, rectangle(50, 90, 200, 200));
txt2.caption(L"aaaa\nbbbb\ncccc\n");
API::eat_tabstop(txt, false);
API::eat_tabstop(txt2, false);
panel.hide();
fm.show();
exec();
} |
A new fix has been checked into hotfix branch. |
Thank you for the fix. But some of hidden widgets still rendered after refocusing the window so unfortunately still not perfect. Please run below program and test below procedures.
#include <nana/gui.hpp>
#include <nana/gui/widgets/textbox.hpp>
#include <nana/gui/widgets/panel.hpp>
#include <nana/gui/widgets/button.hpp>
using namespace nana;
int main()
{
using namespace nana;
form fm(API::make_center(500, 300));
fm.caption(L"tabstop test");
panel<true> panel(fm, rectangle(fm.size()));
textbox txt(panel, rectangle{50, 50, 100, 30});
txt.multi_lines(false);
txt.caption(L"aaaa");
textbox txt2(panel, rectangle(50, 90, 200, 200));
txt2.caption(L"aaaa\nbbbb\ncccc\n");
API::eat_tabstop(txt, false);
API::eat_tabstop(txt2, false);
button btn(panel, rectangle(300, 150, 100, 50));
btn.caption("hide");
btn.events().click([&](){
panel.hide();
});
fm.show();
exec();
}
Losing focus and regaining focus of the window causes the same result. With following procedures, not only the button but also a textbox in the panel is still displayed though the panel was hidden.
The ghost image is ephemeral but still undesirable. |
Hi, a fix has been checked into the hotfix branch, Thanks for your feedback |
Hi, thank you for the fix. I confirmed that your recent fix has solved the ghost image problem. One of the problems is though parent widget is hidden, pressing tab key switches widget focus into hidden textbox and its cares is displayed. To reproduce the issue, please test below.
The other problem is buttons somehow stop responding enter key.
#include <nana/gui.hpp>
#include <nana/gui/widgets/textbox.hpp>
#include <nana/gui/widgets/panel.hpp>
#include <nana/gui/widgets/button.hpp>
using namespace nana;
int main()
{
using namespace nana;
form fm(API::make_center(500, 410));
fm.caption(L"tabstop test");
panel<true> panel(fm, rectangle(point(0,0), size(180,350)));
color c;
panel.bgcolor(c.from_rgb(0, 100, 0));
textbox txt(panel, rectangle{50, 50, 100, 30});
txt.multi_lines(false);
txt.caption(L"aaaa");
textbox txt2(panel, rectangle(50, 90, 100, 200));
txt2.caption(L"aaaa\nbbbb\ncccc\n");
button btn_hide_panel(fm, rectangle(200, 150, 100, 50));
btn_hide_panel.caption("hide panel");
btn_hide_panel.events().click([&](){
panel.hide();
});
button btn_show_panel(fm, rectangle(200, 210, 100, 50));
btn_show_panel.caption("show panel");
btn_show_panel.events().click([&](){
panel.show();
});
button btn_hide(fm, rectangle(310, 150, 100, 50));
btn_hide.caption("hide");
btn_hide.events().click([&](){
txt.hide();
txt2.hide();
});
button btn_show(fm, rectangle(310, 210, 100, 50));
btn_show.caption("show");
btn_show.events().click([&](){
txt.show();
txt2.show();
});
API::eat_tabstop(txt, false);
API::eat_tabstop(txt2, false);
API::eat_tabstop(btn_hide_panel, false);
API::eat_tabstop(btn_show_panel, false);
API::eat_tabstop(btn_hide, false);
API::eat_tabstop(btn_show, false);
fm.show();
exec();
}
|
pressing space on a button will trigger click event
Any feedback is appreciated |
Hi, thank you for the fix. I confirmed that two tiny problems I mentioned in my previous post are resolved now. However, setting focus to hidden widget by API shows a caret. button btn_txt_set_focus(fm, rectangle(310, 270, 100, 50));
btn_txt_set_focus.caption("txt set focus");
btn_txt_set_focus.events().click([&](){
txt.focus();
}); |
Fix it again, wait for your test |
Thank you for the fix. I see no more caret on hidden widget. |
I think hidden widgets should not retain focus. If it has a focus, its focus should be lost.
The text was updated successfully, but these errors were encountered: