2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

plClipboard

This commit is contained in:
Bartek Bok
2012-03-04 11:57:45 +01:00
parent 348858aef1
commit 9bd019fbf3
4 changed files with 214 additions and 3 deletions

View File

@ -61,6 +61,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h"
#include "hsResMgr.h"
#include "../pnInputCore/plKeyMap.h"
#include "../plClipboard/plClipboard.h"
#include <locale>
@ -501,6 +502,29 @@ hsBool pfGUIEditBoxMod::HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef
DoSomething(); // Query WasEscaped() to see if it was escape vs enter
return true;
}
else if (modifiers & pfGameGUIMgr::kCtrlDown)
{
if (key == KEY_C)
{
plClipboard::GetInstance().SetClipboardText(fBuffer);
}
else if (key == KEY_V)
{
wchar_t* contents = plClipboard::GetInstance().GetClipboardText();
size_t len = wcslen(contents);
if (len > 0) {
wchar_t* insertTarget = fBuffer + fCursorPos;
size_t bufferTailLen = wcslen(insertTarget);
if (fCursorPos + len + bufferTailLen < fBufferSize) {
memmove(insertTarget + len, insertTarget, bufferTailLen * sizeof(wchar_t));
memcpy(insertTarget, contents, len * sizeof(wchar_t));
fCursorPos += len;
HandleExtendedEvent( kValueChanging );
}
}
delete contents;
}
}
else
{
fIgnoreNextKey = false;

View File

@ -60,6 +60,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "../plGImage/plDynamicTextMap.h"
#include "plgDispatch.h"
#include "hsResMgr.h"
#include "../plClipboard/plClipboard.h"
//// Tiny Helper Class ///////////////////////////////////////////////////////
@ -1172,9 +1173,6 @@ hsBool pfGUIMultiLineEditCtrl::HandleKeyEvent( pfGameGUIMgr::EventType event, pl
if ((fPrevCtrl || fNextCtrl) && (fLineStarts.GetCount() <= GetFirstVisibleLine()))
return true; // we're ignoring if we can't actually edit our visible frame (and we're linked)
if (modifiers & pfGameGUIMgr::kCtrlDown)
return true; // we're ignoring ctrl key events
if( event == pfGameGUIMgr::kKeyDown || event == pfGameGUIMgr::kKeyRepeat )
{
// Use arrow keys to do our dirty work
@ -1219,6 +1217,19 @@ hsBool pfGUIMultiLineEditCtrl::HandleKeyEvent( pfGameGUIMgr::EventType event, pl
// fEscapedFlag = true;
DoSomething(); // Query WasEscaped() to see if it was escape vs enter
}
else if (modifiers & pfGameGUIMgr::kCtrlDown)
{
if (key == KEY_C)
{
plClipboard::GetInstance().SetClipboardText(fBuffer.AcquireArray());
}
else if (key == KEY_V)
{
wchar_t* contents = plClipboard::GetInstance().GetClipboardText();
InsertString(contents);
delete contents;
}
}
else
{
fIgnoreNextKey = false;