3 ms·
> Let me copy text so I can paste it. I'm guilty of doing this because in my game people kept accidentally double clicking and selecting all the text in the UI
by Kiro 3y ago
> Let me copy text so I can paste it.
I'm guilty of doing this because in my game people kept accidentally double clicking and selecting all the text in the UI. What are the best practices around this?
- noduerme 3y agoThere's nothing wrong with that. A game UI is where you should block text selection. Web-based games that let you accidentally select UI text look unprofessional. I think the author is talking about informational or business apps.
- yonatan8070 3y agoI was reading some article a while back, and as I read I like to highlight what I'm reading with my mouse, but that particular website decided that when I try to highlight text, the appropriate reaction from the site would be a tooltip saying that highlighting is not allowed... So I opened the devtools and copied the whole thing out of spite
- noduerme 3y agoAt least they were being honest about the design decision by actually telling you. Just as a matter of polishing my apps, I usually go through and make sure that pages that might be printed or PDF-copied will print well, that everything selects where someone might want to copy text, and doesn't select where they're clicking any UI element resembling a button. In other words, I try to make all text fields selectable and printable, and everything else act as a graphic (even if it has some text on it).
- ricardo81 3y agoI've seen pages that listen for the console being opened, and would redirect to a Rick Roll when you did. It was a dodgy site though.
- noduerme 3y agoOn some of my old sites I used to check for whether the document was in an iframe, and go into an infinite loop if it was. The trick is to loop/delay slow enough to not trigger the "script is not responding", but enough to make the browser hellishly unresponsive. Back in the Flash days I had a cherry bomb I'd put in my code that would crash decompilers in a similar way, if it found _root.stage.parent. It would also phone home first ;)
- ricardo81 3y agoI'd guess it'd be to limit your custom behaviour to the element it applies to, rather than potentially the whole doc, or multiple pages etc.
- nicbou 3y agoCSS lets you set that behaviour per element
- creata 3y agoImo that's fine. In fact, it's annoying when people (e.g., the "5 seconds" rewind in the YouTube player) don't do this. Even if it's often abused, user-select exists for a reason. [But if there is some text in your game that you think users might ever want to copy, please make it selectable!]
- shadowgovt 3y agoIn an ideal world, we really should have had another button or key combo for "I want to select the text" that isn't overloaded on "I want to select in general." The old way was fine when word processors and other apps were completely separate beasts, but the web has blurred all of that and we are unfortunately albatross'd to decisions made in the past. I want a fifth mouse button where 5-drag always means "select text" independent of all other UI content and as a result all text is selectable because text selection and other manipulations are totally different operations (at the event layer; "mouse down" and "mouse textselect" would be two different events). Wishful thinking; we're stuck with the UI we have.