changeset 1976:bb6612959961

new feature: added support for clipboard interaction with the game (works for single line and multi line CEGUI edit-boxes.
author thegusty999
date Fri, 28 Oct 2011 08:01:37 +0000
parents 611a1ae4457b
children 391b3e152d50
files src/gui/application.cpp src/gui/mainwindow.cpp
diffstat 2 files changed, 37 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui/application.cpp	Fri Oct 28 07:59:21 2011 +0000
+++ b/src/gui/application.cpp	Fri Oct 28 08:01:37 2011 +0000
@@ -46,6 +46,9 @@
 // Add the material manager to allow setting shadow techniques
 #include <OgreMaterialManager.h>
 
+// Clipboard singleton created here.
+#include "clipboard.h"
+
 
 /**
 	Application constructor. Will call the init function.
@@ -992,7 +995,10 @@
 	mgr->setFadeInTime(200.0f);
 	mgr->setFadeOutTime(200.0f);
 	mgr->setVisibleTime(0.0f);
-	
+
+	// Create the clipboard singleton
+	new SWUtil::Clipboard ();
+
 	return true;
 }
 
--- a/src/gui/mainwindow.cpp	Fri Oct 28 07:59:21 2011 +0000
+++ b/src/gui/mainwindow.cpp	Fri Oct 28 08:01:37 2011 +0000
@@ -44,11 +44,15 @@
 #include "tooltipmanager.h"
 #include "ceguiutility.h"
 
+// Access the OS clipboard.
+#include "clipboard.h"
+
 #ifdef BUILD_TOOLS
 #include "debugpanel.h"
 #include "contenteditor.h"
 #endif
 
+
 MainWindow::MainWindow(Ogre::Root* ogreroot, CEGUI::System* ceguisystem,Ogre::RenderWindow* window,Document* doc)
 {
 	m_ogre_root = ogreroot;
@@ -2677,6 +2681,32 @@
 	{
 		m_document->getGUIState()->m_shift_hold = true;
 	}
+
+	// Test for copy paste operations.
+	if (evt.key == OIS::KC_C)
+	{
+		if (m_keyboard->isModifierDown (OIS::Keyboard::Ctrl))
+		{
+			DEBUG ("MainWindow:: ctrl + c pressed!");
+			SWUtil::Clipboard::getSingletonPtr ()->copy ();
+		}
+	}
+	else if (evt.key == OIS::KC_X)
+	{
+		if (m_keyboard->isModifierDown (OIS::Keyboard::Ctrl))
+		{
+			DEBUG ("MainWindow:: ctrl + X pressed!");
+			SWUtil::Clipboard::getSingletonPtr ()->cut ();
+		}
+	}
+	else if (evt.key == OIS::KC_V)
+	{
+		if (m_keyboard->isModifierDown (OIS::Keyboard::Ctrl))
+		{
+			DEBUG ("MainWindow:: ctrl + V pressed!");
+			SWUtil::Clipboard::getSingletonPtr ()->paste ();
+		}
+	}
 	
 	if (!ret)
 	{