Skip to content
This repository
Browse code

Modify GUIEditControl to use the new paste code

  • Loading branch information...
commit 30f8944d1b882372207c1596cd10c3800602d8c9 1 parent 26976c6
John Rennie authored

Showing 1 changed file with 15 additions and 22 deletions. Show diff stats Hide diff stats

  1. 37  xbmc/guilib/GUIEditControl.cpp
37  xbmc/guilib/GUIEditControl.cpp
@@ -27,6 +27,7 @@
27 27
 #include "Key.h"
28 28
 #include "LocalizeStrings.h"
29 29
 #include "XBDateTime.h"
  30
+#include "windowing/WindowingFactory.h"
30 31
 #include "utils/md5.h"
31 32
 
32 33
 #if defined(TARGET_DARWIN)
@@ -577,29 +578,21 @@ void CGUIEditControl::OnSMSCharacter(unsigned int key)
577 578
 
578 579
 void CGUIEditControl::OnPasteClipboard()
579 580
 {
580  
-#if defined(TARGET_DARWIN_OSX)
581  
-  const char *szStr = Cocoa_Paste();
582  
-  if (szStr)
583  
-  {
584  
-    m_text2 += szStr;
585  
-    m_cursorPos+=strlen(szStr);
586  
-    UpdateText();
587  
-  }
588  
-#elif defined TARGET_WINDOWS
589  
-  if (OpenClipboard(g_hWnd))
  581
+  CStdStringW pasted_text;
  582
+
  583
+// Get text from the clipboard
  584
+  pasted_text = g_Windowing.GetClipboard();
  585
+
  586
+  // Insert the pasted text at the current cursor position.
  587
+  if (pasted_text.length() > 0)
590 588
   {
591  
-    HGLOBAL hglb = GetClipboardData(CF_TEXT);
592  
-    if (hglb != NULL)
593  
-    {
594  
-      LPTSTR lptstr = (LPTSTR)GlobalLock(hglb);
595  
-      if (lptstr != NULL)
596  
-      {
597  
-        m_text2 = (char*)lptstr;
598  
-        GlobalUnlock(hglb);
599  
-      }
600  
-    }
601  
-    CloseClipboard();
  589
+    CStdStringW left_end = m_text2.Left(m_cursorPos);
  590
+    CStdStringW right_end = m_text2.Right(m_text2.length() - m_cursorPos);
  591
+
  592
+    m_text2 = left_end;
  593
+    m_text2.append(pasted_text);
  594
+    m_text2.append(right_end);
  595
+    m_cursorPos += pasted_text.length();
602 596
     UpdateText();
603 597
   }
604  
-#endif
605 598
 }

0 notes on commit 30f8944

Please sign in to comment.
Something went wrong with that request. Please try again.