diff options
author | Desour <vorunbekannt75@web.de> | 2022-08-23 18:55:08 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-03-24 17:59:06 +0100 |
commit | d86abb40c1276ec74c72caef664d8efe3915c190 (patch) | |
tree | 1f19889a41a94bd73fe30215f4d5d5e46f5d2107 /source | |
parent | 53b9eaa83172478f9ddffb88d946801a1c57c8f0 (diff) | |
download | irrlicht-d86abb40c1276ec74c72caef664d8efe3915c190.tar.xz |
CGUIEditBox: Use primary selection
This is essentially the same as the commit in the minetest repo for GUIEditBox.
Diffstat (limited to 'source')
-rw-r--r-- | source/Irrlicht/CGUIEditBox.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source/Irrlicht/CGUIEditBox.cpp b/source/Irrlicht/CGUIEditBox.cpp index cf4b64e..24b8099 100644 --- a/source/Irrlicht/CGUIEditBox.cpp +++ b/source/Irrlicht/CGUIEditBox.cpp @@ -1135,6 +1135,34 @@ bool CGUIEditBox::processMouse(const SEvent& event) return true;
}
}
+ case EMIE_MMOUSE_PRESSED_DOWN: {
+ if (!AbsoluteClippingRect.isPointInside(core::position2d<s32>(
+ event.MouseInput.X, event.MouseInput.Y)))
+ return false;
+
+ if (!Environment->hasFocus(this)) {
+ BlinkStartTime = os::Timer::getTime();
+ }
+
+ // move cursor and disable marking
+ CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
+ MouseMarking = false;
+ setTextMarkers(CursorPos, CursorPos);
+
+ // paste from the primary selection
+ inputString([&] {
+ irr::core::stringw inserted_text;
+ if (!Operator)
+ return inserted_text;
+ const c8 *inserted_text_utf8 = Operator->getTextFromPrimarySelection();
+ if (!inserted_text_utf8)
+ return inserted_text;
+ core::multibyteToWString(inserted_text, inserted_text_utf8);
+ return inserted_text;
+ }());
+
+ return true;
+ }
default:
break;
}
@@ -1624,6 +1652,17 @@ void CGUIEditBox::setTextMarkers(s32 begin, s32 end) {
MarkBegin = begin;
MarkEnd = end;
+
+ if (!PasswordBox && Operator && MarkBegin != MarkEnd) {
+ // copy to primary selection
+ const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
+ const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
+
+ core::stringc s;
+ wStringToMultibyte(s, Text.subString(realmbgn, realmend - realmbgn));
+ Operator->copyToPrimarySelection(s.c_str());
+ }
+
sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED);
}
}
|