Skip to content

Commit 93f43c8

Browse files
SmallJokersfan5
authored andcommittedMay 22, 2021
GUIEditBox: Allow selecting and copying read-only texts
1 parent 4152227 commit 93f43c8

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed
 

‎src/gui/guiEditBox.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ bool GUIEditBox::OnEvent(const SEvent &event)
232232

233233
bool GUIEditBox::processKey(const SEvent &event)
234234
{
235-
if (!m_writable) {
236-
return false;
237-
}
238-
239235
if (!event.KeyInput.PressedDown)
240236
return false;
241237

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

530+
if (!m_writable)
531+
return false;
532+
534533
if (m_passwordbox || !m_operator || m_mark_begin == m_mark_end)
535534
return false;
536535

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

557556
bool GUIEditBox::onKeyControlV(const SEvent &event, s32 &mark_begin, s32 &mark_end)
558557
{
559-
if (!isEnabled())
558+
if (!isEnabled() || !m_writable)
560559
return false;
561560

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

603602
bool GUIEditBox::onKeyBack(const SEvent &event, s32 &mark_begin, s32 &mark_end)
604603
{
605-
if (!isEnabled() || Text.empty())
604+
if (!isEnabled() || Text.empty() || !m_writable)
606605
return false;
607606

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

641640
bool GUIEditBox::onKeyDelete(const SEvent &event, s32 &mark_begin, s32 &mark_end)
642641
{
643-
if (!isEnabled() || Text.empty())
642+
if (!isEnabled() || Text.empty() || !m_writable)
644643
return false;
645644

646645
core::stringw s;

0 commit comments

Comments
 (0)
Please sign in to comment.