mirror of https://github.com/aseprite/aseprite.git
Merge f04678e407
into c904c41b39
This commit is contained in:
commit
b637f315c0
|
@ -128,6 +128,15 @@ int Entry::lastCaretPos() const
|
|||
return int(m_boxes.size() - 1);
|
||||
}
|
||||
|
||||
gfx::Point Entry::caretPosOnScreen() const
|
||||
{
|
||||
const gfx::Point caretPos = getCharBoxBounds(m_caret).point2();
|
||||
const os::Window* nativeWindow = display()->nativeWindow();
|
||||
const gfx::Point pos = nativeWindow->pointToScreen(caretPos + bounds().origin());
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void Entry::setCaretPos(const int pos)
|
||||
{
|
||||
gfx::Size caretSize = theme()->getEntryCaretSize(this);
|
||||
|
@ -160,6 +169,8 @@ void Entry::setCaretPos(const int pos)
|
|||
startTimer();
|
||||
m_state = true;
|
||||
|
||||
os::System::instance()->setTextInput(true, caretPosOnScreen());
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
@ -251,7 +262,7 @@ gfx::Rect Entry::getEntryTextBounds() const
|
|||
return onGetEntryTextBounds();
|
||||
}
|
||||
|
||||
gfx::Rect Entry::getCharBoxBounds(const int i)
|
||||
gfx::Rect Entry::getCharBoxBounds(const int i) const
|
||||
{
|
||||
ASSERT(i >= 0 && i < int(m_boxes.size()));
|
||||
if (i >= 0 && i < int(m_boxes.size()))
|
||||
|
@ -288,8 +299,9 @@ bool Entry::onProcessMessage(Message* msg)
|
|||
}
|
||||
|
||||
// Start processing dead keys
|
||||
if (m_translate_dead_keys)
|
||||
os::System::instance()->setTextInput(true);
|
||||
if (m_translate_dead_keys) {
|
||||
os::System::instance()->setTextInput(true, caretPosOnScreen());
|
||||
}
|
||||
break;
|
||||
|
||||
case kFocusLeaveMessage:
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
|
||||
int caretPos() const { return m_caret; }
|
||||
int lastCaretPos() const;
|
||||
gfx::Point caretPosOnScreen() const;
|
||||
|
||||
void setCaretPos(int pos);
|
||||
void setCaretToEnd();
|
||||
|
@ -76,7 +77,7 @@ public:
|
|||
obs::signal<void()> Change;
|
||||
|
||||
protected:
|
||||
gfx::Rect getCharBoxBounds(int i);
|
||||
gfx::Rect getCharBoxBounds(int i) const;
|
||||
|
||||
// Events
|
||||
bool onProcessMessage(Message* msg) override;
|
||||
|
|
Loading…
Reference in New Issue