Skip to content

Commit

Permalink
GUIEditBox: Allow selecting and copying read-only texts
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker authored and sfan5 committed May 22, 2021
1 parent 4152227 commit 93f43c8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/gui/guiEditBox.cpp
Expand Up @@ -232,10 +232,6 @@ bool GUIEditBox::OnEvent(const SEvent &event)

bool GUIEditBox::processKey(const SEvent &event)
{
if (!m_writable) {
return false;
}

if (!event.KeyInput.PressedDown)
return false;

Expand Down Expand Up @@ -531,6 +527,9 @@ bool GUIEditBox::onKeyControlX(const SEvent &event, s32 &mark_begin, s32 &mark_e
// First copy to clipboard
onKeyControlC(event);

if (!m_writable)
return false;

if (m_passwordbox || !m_operator || m_mark_begin == m_mark_end)
return false;

Expand All @@ -556,7 +555,7 @@ bool GUIEditBox::onKeyControlX(const SEvent &event, s32 &mark_begin, s32 &mark_e

bool GUIEditBox::onKeyControlV(const SEvent &event, s32 &mark_begin, s32 &mark_end)
{
if (!isEnabled())
if (!isEnabled() || !m_writable)
return false;

// paste from the clipboard
Expand Down Expand Up @@ -602,7 +601,7 @@ bool GUIEditBox::onKeyControlV(const SEvent &event, s32 &mark_begin, s32 &mark_e

bool GUIEditBox::onKeyBack(const SEvent &event, s32 &mark_begin, s32 &mark_end)
{
if (!isEnabled() || Text.empty())
if (!isEnabled() || Text.empty() || !m_writable)
return false;

core::stringw s;
Expand Down Expand Up @@ -640,7 +639,7 @@ bool GUIEditBox::onKeyBack(const SEvent &event, s32 &mark_begin, s32 &mark_end)

bool GUIEditBox::onKeyDelete(const SEvent &event, s32 &mark_begin, s32 &mark_end)
{
if (!isEnabled() || Text.empty())
if (!isEnabled() || Text.empty() || !m_writable)
return false;

core::stringw s;
Expand Down

0 comments on commit 93f43c8

Please sign in to comment.