forked from mirror/openmw-tes3mp
Use MyGUI clipboard events for MyGUI 3.2.1+ (Fixes #1846)
Note that only <= 3.2.0 and >= 3.2.1 are supported, any SVN version between them might still exhibit duplicate text pasting.
This commit is contained in:
parent
3d47f2ceb0
commit
dcddd9a07c
3 changed files with 39 additions and 0 deletions
|
@ -206,6 +206,15 @@ namespace MWGui
|
|||
mVideoWidget = mVideoBackground->createWidgetReal<VideoWidget>("ImageBox", 0,0,1,1, MyGUI::Align::Default);
|
||||
mVideoWidget->setNeedMouseFocus(true);
|
||||
mVideoWidget->setNeedKeyFocus(true);
|
||||
|
||||
#if MYGUI_VERSION >= MYGUI_DEFINE_VERSION(3,2,1)
|
||||
// Removes default MyGUI system clipboard implementation, which supports windows only
|
||||
MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear();
|
||||
MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear();
|
||||
|
||||
MyGUI::ClipboardManager::getInstance().eventClipboardChanged += MyGUI::newDelegate(this, &WindowManager::onClipboardChanged);
|
||||
MyGUI::ClipboardManager::getInstance().eventClipboardRequested += MyGUI::newDelegate(this, &WindowManager::onClipboardRequested);
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowManager::initUI()
|
||||
|
@ -1699,4 +1708,27 @@ namespace MWGui
|
|||
{
|
||||
mScreenFader->setFactor(factor);
|
||||
}
|
||||
|
||||
void WindowManager::onClipboardChanged(const std::string &_type, const std::string &_data)
|
||||
{
|
||||
if (_type == "Text")
|
||||
SDL_SetClipboardText(MyGUI::TextIterator::getOnlyText(MyGUI::UString(_data)).asUTF8().c_str());
|
||||
}
|
||||
|
||||
void WindowManager::onClipboardRequested(const std::string &_type, std::string &_data)
|
||||
{
|
||||
if (_type != "Text")
|
||||
return;
|
||||
char* text=0;
|
||||
text = SDL_GetClipboardText();
|
||||
if (text)
|
||||
{
|
||||
// MyGUI's clipboard might still have color information, to retain that information, only set the new text
|
||||
// if it actually changed (clipboard inserted by an external application)
|
||||
if (MyGUI::TextIterator::getOnlyText(_data) != text)
|
||||
_data = text;
|
||||
}
|
||||
SDL_free(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -448,6 +448,9 @@ namespace MWGui
|
|||
void onVideoKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char);
|
||||
|
||||
void sizeVideo(int screenWidth, int screenHeight);
|
||||
|
||||
void onClipboardChanged(const std::string& _type, const std::string& _data);
|
||||
void onClipboardRequested(const std::string& _type, std::string& _data);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -498,6 +498,7 @@ namespace MWInput
|
|||
|
||||
void InputManager::keyPressed( const SDL_KeyboardEvent &arg )
|
||||
{
|
||||
#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3,2,0)
|
||||
// Cut, copy & paste
|
||||
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||
if (focus)
|
||||
|
@ -537,6 +538,7 @@ namespace MWInput
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
|
||||
|
||||
|
@ -550,7 +552,9 @@ namespace MWInput
|
|||
|
||||
// Clear MyGUI's clipboard, so it doesn't interfere with our own clipboard implementation.
|
||||
// We do not use MyGUI's clipboard manager because it doesn't support system clipboard integration with SDL.
|
||||
#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3,2,0)
|
||||
MyGUI::ClipboardManager::getInstance().clearClipboardData("Text");
|
||||
#endif
|
||||
}
|
||||
|
||||
void InputManager::textInput(const SDL_TextInputEvent &arg)
|
||||
|
|
Loading…
Reference in a new issue