From d528b5c94d30f36f73196ab7ec5b527aa2542764 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 23 Jun 2015 00:11:47 +0800 Subject: [PATCH] fix an issue that caret doesn't move when moving the parent widget. --- include/nana/gui/detail/inner_fwd_implement.hpp | 1 - source/gui/detail/linux_X11/bedrock.cpp | 6 +++++- source/gui/detail/win32/bedrock.cpp | 8 +++----- source/gui/detail/window_manager.cpp | 15 +++++++-------- source/gui/widgets/skeletons/text_editor.cpp | 2 ++ 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/nana/gui/detail/inner_fwd_implement.hpp b/include/nana/gui/detail/inner_fwd_implement.hpp index 5384aec4..833c7668 100644 --- a/include/nana/gui/detail/inner_fwd_implement.hpp +++ b/include/nana/gui/detail/inner_fwd_implement.hpp @@ -121,7 +121,6 @@ namespace nana{ { core_window_t* pressed{nullptr}; //The handle to a window which is being pressed core_window_t* hovered{nullptr}; //the latest window that mouse moved - bool tabstop_focus_changed{false}; //KeyDown may set it true, if it is true KeyChar will ignore the message }condition; root_misc(core_window_t * wd, unsigned width, unsigned height) diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index 1a5a1ecc..d484cbb1 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -1032,7 +1032,6 @@ namespace detail { brock.wd_manager.set_focus(the_next, false); brock.wd_manager.do_lazy_refresh(the_next, true); - root_runtime->condition.tabstop_focus_changed = true; } } else if(keyboard::alt == keychar) @@ -1081,6 +1080,7 @@ namespace detail break; } case XLookupChars: + if (msgwnd->flags.enabled) { const ::nana::char_t* charbuf; #if defined(NANA_UNICODE) @@ -1097,6 +1097,10 @@ namespace detail arg.ignore = false; arg.key = charbuf[i]; + // When tab is pressed, only tab-eating mode is allowed + if ((keyboard::tab == arg.key) && !(msgwnd->flags.tab & tab_type::eating)) + continue; + if(context.is_alt_pressed) { arg.ctrl = arg.shift = false; diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index daeb369d..8cd5231c 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -1408,7 +1408,6 @@ namespace detail brock.wd_manager.set_focus(the_next, false); brock.wd_manager.do_lazy_refresh(msgwnd, false); brock.wd_manager.do_lazy_refresh(the_next, true); - root_runtime->condition.tabstop_focus_changed = true; } } else @@ -1437,9 +1436,10 @@ namespace detail break; case WM_CHAR: msgwnd = brock.focus(); - if(false == root_runtime->condition.tabstop_focus_changed) + if (msgwnd && msgwnd->flags.enabled) { - if(msgwnd && msgwnd->flags.enabled) + // When tab is pressed, only tab-eating mode is allowed + if ((9 != wParam) || (msgwnd->flags.tab & tab_type::eating)) { arg_keyboard arg; arg.evt_code = event_code::key_char; @@ -1455,8 +1455,6 @@ namespace detail brock.wd_manager.do_lazy_refresh(msgwnd, false); } } - else - root_runtime->condition.tabstop_focus_changed = false; return 0; case WM_KEYUP: if(wParam != 18) //MUST NOT BE AN ALT diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index ba6af080..30c497fa 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -493,9 +493,6 @@ namespace detail wd->pos_owner.y = y; _m_move_core(wd, delta); - if(wd->together.caret && wd->together.caret->visible()) - wd->together.caret->update(); - auto &brock = bedrock::instance(); arg_move arg; arg.window_handle = reinterpret_cast(wd); @@ -522,7 +519,7 @@ namespace detail auto & brock = bedrock::instance(); bool moved = false; const bool size_changed = (r.width != wd->dimension.width || r.height != wd->dimension.height); - if(wd->other.category != category::root_tag::value) + if(category::flags::root != wd->other.category) { //Move child widgets if(r.x != wd->pos_owner.x || r.y != wd->pos_owner.y) @@ -533,9 +530,6 @@ namespace detail _m_move_core(wd, delta); moved = true; - if(wd->together.caret && wd->together.caret->visible()) - wd->together.caret->update(); - arg_move arg; arg.window_handle = reinterpret_cast(wd); arg.x = r.x; @@ -1425,7 +1419,12 @@ namespace detail if(wd->other.category != category::root_tag::value) //A root widget always starts at (0, 0) and its childs are not to be changed { wd->pos_root += delta; - if(wd->other.category == category::frame_tag::value) + if (category::flags::frame != wd->other.category) + { + if (wd->together.caret && wd->together.caret->visible()) + wd->together.caret->update(); + } + else native_interface::move_window(wd->other.attribute.frame->container, wd->pos_root.x, wd->pos_root.y); for (auto child : wd->children) diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 0a2f9261..69cf0b6a 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -1482,6 +1482,8 @@ namespace nana{ namespace widgets behavior_->pre_calc_lines(width_pixels()); _m_scrollbar(); + + move_caret(points_.caret); return true; }