diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 7ade80ae4c..36b7b036e7 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -16,6 +16,7 @@ #include "buffer.h" #include "bufferparams.h" #include "BufferView.h" +#include "coordcache.h" #include "CutAndPaste.h" #include "cursor.h" #include "debug.h" @@ -220,6 +221,16 @@ void InsetText::drawSelection(PainterInfo & pi, int x, int y) const } +bool InsetText::covers(BufferView & bv, int x, int y) const +{ + return bv.coordCache().getInsets().has(this) + && x >= xo(bv) + && x <= xo(bv) + width() + (Wide() ? text_.maxwidth_ : 0) + && y >= yo(bv) - ascent() + && y <= yo(bv) + descent(); +} + + docstring const InsetText::editMessage() const { return _("Opened Text Inset"); diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 578109343f..6eef99eac4 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -52,6 +52,8 @@ public: void draw(PainterInfo & pi, int x, int y) const; /// draw inset selection void drawSelection(PainterInfo & pi, int x, int y) const; + /// are we inside the area covered by the inset? + virtual bool covers(BufferView & bv, int x, int y) const; /// virtual lyx::docstring const editMessage() const; ///