Clipboard Access

I’m torn between this being useful and it being a security risk. People have already addressed the idea of people just having their clipboard set to whatever, but that’s an inherent risk regardless. I’m not inherently against a notification telling people their clipboard has been changed, but it’d get annoying.

Maybe have two different methods? Have one that sets the clipboard only for that particular instance in ROBLOX (that’d be on ROBLOX’s part, though), and have one that requires user confirmation to set the clipboard in its actuality? Hell, even make the user confirmation cache per session so you don’t have to be asked more than once. Would mitigate the aforementioned issue with people just having their clipboard set by any old place.

As for getting the clipboard? Yeah, it’s not reasonable to just get the clipboard, unless it was confirmed by the user, again. A clipboard pasted event would work for most cases, but there’s always the edge cases. Perhaps just allow the developer to get the clipboard contents if its been set by ROBLOX (dunno how’d you keep track of that, it might have to be in the same session) and ask for confirmation on the user’s part otherwise.

This is a unique issue because it affects people outside of the game. A game spams audio? You leave the game. A plugin destroys your place? You uninstall it and reload the place. You accidentally paste your password into some guy’s plugin? …Well you’re SOL.

That’s just my opinion though. Could be entirely unreasonable.

Not useful. Textboxes that don’t suck are great, but it doesn’t provide as much functionality:

  • I can’t copy text from TextLabels/(Buttons?) like how I can by highlighting your text on Discourse to quote you
  • As a plugin developer I can’t use the clipboard for ROBLOX objects. The whole point of having access to the clipboard is so that I don’t have to do Selection:Set() on some weird objects I hide in Geometry and can just add them to the clipboard directly

I don’t understand the big deal with “security”. Someone setting your clipboard to something dumb affects you so little. You have to paste without copying something first to even see what the ROBLOX client/studio set your clipboard to, and that’s most likely not going to happen. The only “security issue” here is an invented one that’s being over-embellished.

lmao

I mean any text UI. Obviously the whole thing sucks.

I’m down with explicitly setting just objects to the clipboard. I can’t think of any cases for explicitly setting text (assuming that text UI doesn’t suck).

It’s insecure for the same reason that email attachments are insecure. It affects you in particular very little, because you’re careful and knowledgeable. A lot of people aren’t, though. Another point is that Roblox runs user-generated code on a player’s machine, and they have an interest in keeping the player safe. They aren’t just going to expose operating system functions willy-nilly, even if they’re seemingly harmless.

1 Like

Quick copying. Take this site for example. You can click on the text faces once to copy the whole thing to your clipboard as opposed to manually select the whole thing character by character.

This is not why. It affects everyone little by design. If you want to paste something from your clipboard, you want to paste what you copied earlier. In other words, if anyone pastes something, they’ve already copied something else, even if they weren’t careful/knowledgeable, that overwrites what it’s been set to in ROBLOX.

Nothing’s being exposed, just as the ROBLOX API doesn’t expose the internal C++ code. The API is a controlled interface, and that’s it. I don’t see how this is any different that setting the vibration of a controller for instance – we’re using (controlled) interfaces to manipulate system functions (in a controlled manner) in both cases.

Assuming the text UI didn’t suck, it would have an API for setting the highlighted text, which would let you highlight all the text on-click, or on-focus, or whatever. Most websites already do this, since the JS clipboard API is only a recent addition. The reason it’s recent is because of -you guessed it- security (here’s a neat explanation).

People want to paste what they explicitly copied, not what was automatically set as a side-effect of some other action. By design, every program that copies to the clipboard makes sure the user understands the contents of the clipboard, and that the user initiated the action.

When a programmer wants to expose the clipboard through some API, if they want to ensure that this design is maintained, then they must implement it in particular way. Otherwise, users of that API could use it in a way that goes against the design, affecting the UX of the program.

The clipboard, a component of the OS, is what’s being exposed. At the very end, Roblox would be allowing user-generated data enter the clipboard. So what kind of data is allowed, and how that data gets there, must be considered carefully.

The reason I’m okay with copying instances directly is because it’s effectively impossible to accidentally paste that data into an unintended location, like a URL bar.

3 Likes

If it had text selection, this, and allowed free domain over ROBLOX objects with the clipboard, then that would be enough. Unless someone has anything else to add, that covers all of the use cases I have.

I created Lua Learning, and as I’m typing this, it’s on the Front Page. :grin:

My feedback web-hook, my Roblox messages, and my Discord DMs are all being filled with players asking me to let them copy code examples from the game into Studio. This is a feature that is being requested by many.

As far as I can find, there isn’t a way to do this. Within the game, they can copy paste, but that’s a simple custom clipboard that exists only within the game. I don’t have a method to put it in the user’s actual clipboard.

Has this changed? Will it ever? It’s a really crucial feature for some.

1 Like

I’m currently working to ship a feature that lets you select and copy paste in textboxes on PC. Note that copying from a textbox is already possible on mobile, though it’s clunky when the expectation is being able to tap a button. On desktop, the new functionality requires users to explicitly press ctrl+C, but you will be able to do most of the work for them by doing:

textbox:CaptureFocus()
textbox.CursorPosition = string.len(textbox.Text)
textbox.SelectionStart = 1

which will pre-select the text, and all they have to do is press ctrl+C. In the future we can consider adding a feature for this that works without prompting the user, if this isn’t good enough.

19 Likes

@Tiffblocks Allowing plugins to write to the clipboard would be useful for a plugin I am creating. It would allow the user to easily copy the ID of a mesh/image/sound to their clipboard

Untitled

3 Likes

I would benefit from using this feature. I would use it to allow users to copy a deeplink to their clipboard.

do you not realise??? you can??? already make key loggers???

1 Like

I would love clipboard functionality tbh.

Though even if you restrict it to only in-game copy/pasting, it’s still abusable.
Malicious devs can paste site links into someone’s clipboard.

HOWEVER, one solution to this would be to have the experience ASK the user for permission like plugins do.

A experience can only ask a user for clipboard permission ONCE, if the user clicks “decline” it returns false in script.

Additionally, there could be security options.
Let’s say we have a clipboard service.

local cs = game:GetService("ClipboardService")

local perms = cs:RequestPermission() -- Prompts player with a GUI much like in-game purchases.

if perms == Enum.PermissionLevel.None then
 print("User didn't give permission, clipboard functionality disabled.")

elseif perms == Enum.PermissionLevel.Restricted then
 print("User gave in-game-only clipboard permission.")

elseif perms == Enum.PermissionLevel.Full then
 print("User gave full clipboard permission.")
end

What are the differences between all the modes?

None doesn’t allow any clipboard access.
Both copying and pasting is disabled and will error in script if attempted.

Restricted only allows the game to get text from the clipboard that was also obtained/copied in-game.
This avoids malicious devs from copying potential personal information or passwords someone used to log into a site.

The Full permission gives full clipboard permission.
This let’s the game also read clipboard content from outside the game.

Useful if you want to allow players to save and load their game data locally by letting them save a .txt file to their clipboard.

If you want to load a file from a player’s computer into the game, they can copy the file’s contents (such as local game save and settings data or a midi file for playing musical notes) and ClipboardService can then read that data to do something with it.

I think this implementation is a bit safer perhaps?
And the permission prompt can only be send once in a while to prevent spam.

Alternatively you can also include a “Never ask again” option.

4 Likes

this is a pretty good idea of how to implement it imo, a clipboard system would be nice though couldnt you just use no editable text boxes to copy stuff?

Editable text boxes is an option, I recall you can already do that in Roblox but it feels a bit cheap to do it that way.

I honestly also really wish Roblox had an API for prompting users to save or load a file.
Though, to prevent that from being harmful in any way the file would have to be raw text so it’s not possible to download a exe file or anything.

Just a simple and safe way to save certain things like user settings and whatnot locally would be nice.

Allowing developers to at least set the player’s clipboard would be very useful.

For instance, being able to copy deeplinks for your game with a click of a button so the player can easily share them around (something which I’m sure has been brought up before).

In terms of security—when the game wants to copy something to the player’s clipboard, show a prompt asking “Do you want to copy STRING to your clipboard?”. This makes sure the player knows what’s being copied to their clipboard, and they have the option to deny it on the spot.

1 Like

My use case: I need to copy strings greater than the max text length of 200,000. This makes it impossible to fill a textbox and just copy and paste on my own, since it can’t fit within a textbox. Similarly, it’s far too long to just print to console and copy and paste from there since the output window trims anything above around 130k characters.

What I would like to be able to do: If a user copies and studio is unable to auto-detect something highlighted, it will request input from scripts. Some potential ways to do this:

  1. Call some BindableFunction equivalent - ClipboardService.CopyRequested() which if a result is
    returned, it will then copy to the clipboard.
  2. Take a value from some function CliboardService:SetOnCopy(text)
  3. Merge both of those into a signal ClipboardService.CopyRequested(function() ClipboardService:SetOnCopy(text) end) so I’m not constantly setting SetOnCopy for just in case the user tries to copy something

Case 2 is less favorable - I could set up a context-sensitive screen “hit Ctrl+C to copy to clipboard” that appears when a user clicks an in-game button to copy, but my data is too long to be constantly setting a function like that.
In cases 1/3, I can copy at any point in time which is ideal - (case 3 is added since it supports RBXScriptSignal, and if in-game support is added, I’ll probably need to yield to use HttpService:JSONEncode() and get a proper string for all the data I need to copy and paste)

Similarly, a RBXScriptSignal ClipboardService.OnUserPasted(text) if studio cannot auto-detect a TextBox to fill or some other internal action to fire.

This would be great to have in-game, if not, something like the above would meet the minimum requirements for my use-case if it were a plugin.