fix caret issue

This commit is contained in:
Jinhao
2017-11-02 16:36:23 +08:00
parent 0796c1540b
commit 74f5a8f40b
5 changed files with 26 additions and 17 deletions

View File

@@ -204,6 +204,11 @@ namespace nana
{
return (visible_state::invisible != visibility_);
}
bool caret::activated() const
{
return (visible_state::displayed == visibility_);
}
//end class caret
//struct basic_window
@@ -329,24 +334,18 @@ namespace nana
return false;
}
const basic_window* get_child_caret(const basic_window* wd, bool this_is_a_child)
{
if (this_is_a_child && wd->annex.caret_ptr)
return wd;
for (auto child : wd->children)
{
auto caret_wd = get_child_caret(child, true);
if (caret_wd)
return caret_wd;
}
return nullptr;
}
const basic_window * basic_window::child_caret() const
{
return get_child_caret(this, false);
for (auto child : children) {
//Only return the child who has activated caret.
if (child->annex.caret_ptr && child->annex.caret_ptr->activated())
return child;
auto caret = child->child_caret();
if (caret)
return caret;
}
return nullptr;
}
bool basic_window::is_draw_through() const