ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Illegal Call CopyAllTextToClipboard (https://www.esoui.com/forums/showthread.php?t=6012)

vandel212 01/14/16 11:16 PM

Illegal Call CopyAllTextToClipboard
 
First off let me appologize, it seems as though I have taken over the forum with all my posts. I truely do look for solutions before posting here (Google + Forum search tool + Wiki + API documentation), but being that this isn't the most common programming language, and it revolves around a MMO's API the available info is limited (espeically compared to straight up c# (my bread and butter)). I really appreciate all the help, you guys/gals are fantastic!

Ok, so I found this nifty little thread here with some code on how to copy text to the clipboard. When I run the code, it tells me an addon is trying to make an illegal call to [CopyAllTextToClipboard]. Being that there are addons here that do exactly that, there must be something I'm missing. Any help would be greatly appreciated.

Here is the code that uses it, so when I open up my inbox I get the error (starting at line 12). Right now I'm just trying to get it to copy "Hello World" to the clipboard:

Lua Code:
  1. function CopyMailStuff.ReadableMail(eventCode, mailId) 
  2.     AttachmentsString = ""
  3.     local mail = {}
  4.     mail.senderDisplayName, mail.senderCharacterName, mail.subject, mail.icon, mail.unread, mail.fromSystem, mail.fromCustomerService,
  5.     mail.returned, mail.numAttachments, mail.attachedMoney, mail.codAmount, mail.expiresInDays, mail.secsSinceReceived = GetMailItemInfo(mailId)
  6.  
  7.     if mail.numAttachments > 0 then
  8.         local intAttachmentCounter = 1     
  9.         local intNumberOfAttachments = mail.numAttachments
  10.         AttachmentsString = mailId .. "<,|,>" ..    mail.senderDisplayName .. "<,|,>" .. mail.subject ..
  11.        
  12.         clipBoardControl = WINDOW_MANAGER:CreateControl("Chat2ClipboardControl", GuiRoot, CT_EDITBOX)
  13.         clipBoardControl:SetHidden(true)
  14.         clipBoardControl:SetMaxInputChars(1000)
  15.        
  16.         clipBoardControl:SetText("Hello World")
  17.         clipBoardControl:CopyAllTextToClipboard()  
  18.        
  19.     end
  20. end

circonian 01/15/16 12:28 AM

You can't do it. Your not missing anything, there are no addons that can do it. We used to be able to copy to the clipboard, but they removed our ability to do so. The closest we can do is create an editbox, dump text into it, highlight it, & then the user can manually click cntrl+c to copy it themselves.

votan 01/15/16 12:29 AM

The post is from 2014. This method was made private by ZOS. They don't want to automate (mass) copying of text via clipboard. Since than addons just offer a edit-box and the user has to press the strg-C.
You are not doing something wrong. It is just forbidden.

vandel212 01/15/16 01:38 AM

Quote:

Originally Posted by votan (Post 25494)
The post is from 2014. This method was made private by ZOS. They don't want to automate (mass) copying of text via clipboard. Since than addons just offer a edit-box and the user has to press the strg-C.
You are not doing something wrong. It is just forbidden.

Darn. Thanks for the info.


All times are GMT -6. The time now is 05:08 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI