1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Basic clipboard functionality

This commit is contained in:
Bartek Bok
2012-02-27 21:05:36 +01:00
parent 5bd22e1912
commit d8dd19e093
7 changed files with 241 additions and 5 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>
@ -387,6 +388,30 @@ 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(_TEMP_CONVERT_FROM_WCHAR_T(fBuffer));
}
else if (key == KEY_V)
{
plString contents = plClipboard::GetInstance().GetClipboardText();
plStringBuffer<wchar_t> tmp = contents.ToWchar();
size_t len = tmp.GetSize();
if (len > 0) {
--len; //skip \0 on end
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, tmp.GetData(), len * sizeof(wchar_t));
fCursorPos += len;
HandleExtendedEvent( kValueChanging );
}
}
}
}
else
{
fIgnoreNextKey = false;

View File

@ -60,7 +60,8 @@ 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"
#include "plString.h"
//// Tiny Helper Class ///////////////////////////////////////////////////////
@ -1067,9 +1068,6 @@ hsBool pfGUIMultiLineEditCtrl::HandleKeyEvent( pfGameGUIMgr::EventType event, p
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
@ -1109,13 +1107,28 @@ hsBool pfGUIMultiLineEditCtrl::HandleKeyEvent( pfGameGUIMgr::EventType event, p
DeleteChar();
}
else if( key == KEY_ENTER )
else if( key == KEY_ENTER )
{
if( IsLocked() )
return true;
InsertChar('\n');
}
else if (modifiers & pfGameGUIMgr::kCtrlDown)
{
// Not exactly safe way to do it, since there are control codes inside buffer.
// But what's the worst thing that can happen? Horribly colorful ki-mails?
// Too lazy to worry about that...
if (key == KEY_C)
{
plClipboard::GetInstance().SetClipboardText(_TEMP_CONVERT_FROM_WCHAR_T(fBuffer.AcquireArray()));
}
else if (key == KEY_V)
{
plString contents = plClipboard::GetInstance().GetClipboardText();
InsertString(contents.ToWchar().GetData());
}
}
else if( key == KEY_ESCAPE )
{
// fEscapedFlag = true;