Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modify GUIEditControl to use the new paste code

  • Loading branch information...
commit 30f8944d1b882372207c1596cd10c3800602d8c9 1 parent 26976c6
John Rennie jhsrennie authored
Showing with 15 additions and 22 deletions.
  1. +15 −22 xbmc/guilib/GUIEditControl.cpp
37 xbmc/guilib/GUIEditControl.cpp
View
@@ -27,6 +27,7 @@
#include "Key.h"
#include "LocalizeStrings.h"
#include "XBDateTime.h"
+#include "windowing/WindowingFactory.h"
#include "utils/md5.h"
#if defined(TARGET_DARWIN)
@@ -577,29 +578,21 @@ void CGUIEditControl::OnSMSCharacter(unsigned int key)
void CGUIEditControl::OnPasteClipboard()
{
-#if defined(TARGET_DARWIN_OSX)
- const char *szStr = Cocoa_Paste();
- if (szStr)
- {
- m_text2 += szStr;
- m_cursorPos+=strlen(szStr);
- UpdateText();
- }
-#elif defined TARGET_WINDOWS
- if (OpenClipboard(g_hWnd))
+ CStdStringW pasted_text;
+
+// Get text from the clipboard
+ pasted_text = g_Windowing.GetClipboard();
+
+ // Insert the pasted text at the current cursor position.
+ if (pasted_text.length() > 0)
{
- HGLOBAL hglb = GetClipboardData(CF_TEXT);
- if (hglb != NULL)
- {
- LPTSTR lptstr = (LPTSTR)GlobalLock(hglb);
- if (lptstr != NULL)
- {
- m_text2 = (char*)lptstr;
- GlobalUnlock(hglb);
- }
- }
- CloseClipboard();
+ CStdStringW left_end = m_text2.Left(m_cursorPos);
+ CStdStringW right_end = m_text2.Right(m_text2.length() - m_cursorPos);
+
+ m_text2 = left_end;
+ m_text2.append(pasted_text);
+ m_text2.append(right_end);
+ m_cursorPos += pasted_text.length();
UpdateText();
}
-#endif
}
Please sign in to comment.
Something went wrong with that request. Please try again.