Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Copy/paste with gui objects?

Asked by
0b1w 13
5 years ago

I was curious, in lua learning (roblox.com/games/1334669864) they've added the functionality of copying and pasting. I've searched here, and the dev forum. But I can't find out how it's done. Anyone know?

1 answer

Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

Here's some pseudo code of it. Should help you understand the logic:

when the player presses a key, do the following: 
    If the player presses control, then see what the next button they're going to press is. 
        If they pressed "C", then 
            if there is text highlighted then
                put all the text into a variable named 'clipboard' 
                tell the player that their text has been copied onto the clipboard / highlight text
            end
            --do nothing if there's not any text highlighted
        end

        --player wants to paste...
        else if the player pressed "V" then
            if there is something in our clipboard then
                if all the text is selected then 
                    make the textbox text the clipboard's text
                else if they text isn't selected then
                    add the clipboard text to what's currently in the textbox
                end
            end
        end

        else if the player presses "X" then
            if the player has text selected, then 
                add the text to the clipboard variable 
                make the text in the textbox empty (" ")
            end
        end
    end
end
Ad

Answer this question