Use SDL2 clipboard for edit box
This commit is contained in:
parent
2eaca2091e
commit
cc13d32951
@ -25,11 +25,8 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "IrrlichtDevice.h"
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
#include "CIrrDeviceLinux.h"
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WAYLAND_DEVICE_)
|
||||
#include "CIrrDeviceWayland.h"
|
||||
#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
|
||||
#include "SDL_clipboard.h"
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
|
||||
#include "MacOSX/OSXClipboard.h"
|
||||
@ -124,30 +121,8 @@ void COSOperator::copyToClipboard(const c8* text) const
|
||||
|
||||
OSXCopyToClipboard(text);
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_WAYLAND_DEVICE_)
|
||||
if (IrrDevice != NULL)
|
||||
{
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
if (IrrDevice->getType() == EIDT_X11)
|
||||
{
|
||||
CIrrDeviceLinux* device = dynamic_cast<CIrrDeviceLinux*>(IrrDevice);
|
||||
assert(device);
|
||||
|
||||
device->copyToClipboard(text);
|
||||
}
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WAYLAND_DEVICE_)
|
||||
if (IrrDevice->getType() == EIDT_WAYLAND)
|
||||
{
|
||||
CIrrDeviceWayland* device = dynamic_cast<CIrrDeviceWayland*>(IrrDevice);
|
||||
assert(device);
|
||||
|
||||
device->copyToClipboard(text);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
|
||||
SDL_SetClipboardText(text);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -199,30 +174,8 @@ const c8* COSOperator::getTextFromClipboard() const
|
||||
|
||||
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_WAYLAND_DEVICE_)
|
||||
if (IrrDevice != NULL)
|
||||
{
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
if (IrrDevice->getType() == EIDT_X11)
|
||||
{
|
||||
CIrrDeviceLinux* device = dynamic_cast<CIrrDeviceLinux*>(IrrDevice);
|
||||
assert(device);
|
||||
|
||||
return device->getTextFromClipboard();
|
||||
}
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WAYLAND_DEVICE_)
|
||||
if (IrrDevice->getType() == EIDT_WAYLAND)
|
||||
{
|
||||
CIrrDeviceWayland* device = dynamic_cast<CIrrDeviceWayland*>(IrrDevice);
|
||||
assert(device);
|
||||
|
||||
return device->getTextFromClipboard();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
|
||||
return SDL_GetClipboardText();
|
||||
#else
|
||||
|
||||
return 0;
|
||||
|
@ -468,11 +468,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
|
||||
const s32 realmend = m_mark_begin < m_mark_end ? m_mark_end : m_mark_begin;
|
||||
|
||||
std::u32string s = m_edit_text.substr(realmbgn, realmend - realmbgn);
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
Operator->copyToClipboard(StringUtils::utf32ToWide(s).c_str());
|
||||
#else
|
||||
Operator->copyToClipboard(StringUtils::utf32ToUtf8(s).c_str());
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case IRR_KEY_X:
|
||||
@ -484,11 +480,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
|
||||
|
||||
// copy
|
||||
std::u32string s = m_edit_text.substr(realmbgn, realmend - realmbgn);
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
Operator->copyToClipboard(StringUtils::utf32ToWide(s).c_str());
|
||||
#else
|
||||
Operator->copyToClipboard(StringUtils::utf32ToUtf8(s).c_str());
|
||||
#endif
|
||||
|
||||
if (isEnabled())
|
||||
{
|
||||
@ -516,13 +508,10 @@ bool CGUIEditBox::processKey(const SEvent& event)
|
||||
const s32 realmend = m_mark_begin < m_mark_end ? m_mark_end : m_mark_begin;
|
||||
|
||||
// add new character
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
const std::u32string clipboard =
|
||||
StringUtils::wideToUtf32(Operator->getTextFromClipboard());
|
||||
#else
|
||||
const std::u32string clipboard =
|
||||
StringUtils::utf8ToUtf32(Operator->getTextFromClipboard());
|
||||
#endif
|
||||
char* clipboard_u8 = (char*)Operator->getTextFromClipboard();
|
||||
std::u32string clipboard;
|
||||
if (clipboard_u8)
|
||||
clipboard = StringUtils::utf8ToUtf32(clipboard_u8);
|
||||
if (!clipboard.empty())
|
||||
{
|
||||
if (m_mark_begin == m_mark_end)
|
||||
|
Loading…
Reference in New Issue
Block a user