fix caret issue
This commit is contained in:
parent
0796c1540b
commit
74f5a8f40b
@ -273,6 +273,7 @@ that return a corresponding nana::appearance with predefined values.
|
||||
public:
|
||||
virtual ~caret_interface() = default;
|
||||
|
||||
virtual bool activated() const = 0;
|
||||
virtual void disable_throw() noexcept = 0;
|
||||
|
||||
virtual void effective_range(const rectangle& range) = 0;
|
||||
|
@ -55,6 +55,7 @@ namespace detail
|
||||
void dimension(const size& s) override;
|
||||
void visible(bool visibility) override;
|
||||
bool visible() const override;
|
||||
bool activated() const override;
|
||||
private:
|
||||
basic_window * owner_;
|
||||
point position_;
|
||||
|
@ -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
|
||||
|
@ -151,7 +151,8 @@ namespace nana
|
||||
arg.window_handle = reinterpret_cast<window>(wd);
|
||||
if (emit(event_code::expose, wd, arg, false, get_thread_context()))
|
||||
{
|
||||
const core_window_t * caret_wd = (wd->annex.caret_ptr ? wd : wd->child_caret());
|
||||
//Get the window who has the activated caret
|
||||
const core_window_t * caret_wd = ((wd->annex.caret_ptr && wd->annex.caret_ptr->activated()) ? wd : wd->child_caret());
|
||||
if (caret_wd)
|
||||
{
|
||||
if (exposed)
|
||||
|
@ -1183,6 +1183,13 @@ namespace API
|
||||
auto caret = _m_caret();
|
||||
return (caret && caret->visible());
|
||||
}
|
||||
|
||||
bool activated() const override
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto caret = _m_caret();
|
||||
return (caret && caret->activated());
|
||||
}
|
||||
private:
|
||||
caret_interface* _m_caret() const
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user