SetClipboard: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Dutchman101 (talk | contribs) mNo edit summary |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
This function sets the players clipboard text (what appears when you paste with CTRL + V) | This function sets the players clipboard text (what appears when you paste with CTRL + V) | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool | bool setClipboard ( string theText ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 20: | Line 20: | ||
function( command, ... ) | function( command, ... ) | ||
local text = table.concat({...}, " ") -- if the text has spaces this will turn it into a string | local text = table.concat({...}, " ") -- if the text has spaces this will turn it into a string | ||
local success = | local success = setClipboard( text ) -- set the clipboard and find out if it worked | ||
if success then | if success then | ||
outputChatBox( "Clipboard text set to: " .. text, 0, 255, 0 ) -- if it did, tell the player | outputChatBox( "Clipboard text set to: " .. text, 0, 255, 0 ) -- if it did, tell the player | ||
Line 28: | Line 28: | ||
end | end | ||
) | ) | ||
</syntaxhighlight> | |||
This example is to allow you to copy the words that are written in edit box | |||
<syntaxhighlight lang="lua"> | |||
window = guiCreateWindow(47, 105, 262, 56, "example By ProGamer", false) | |||
edit = guiCreateEdit(47, 105, 262, 56, "", false, window) | |||
button1 = guiCreateButton(58, 220, 234, 46, "copy", false, window) | |||
function clickedButton1() | |||
local text = guiGetText(edit) | |||
setClipboard(text) | |||
end | |||
addEventHandler("onClientGUIClick", button1, clickedButton1, false) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client_utility_functions}} | {{Client_utility_functions}} |
Latest revision as of 10:34, 2 July 2021
This function sets the players clipboard text (what appears when you paste with CTRL + V)
Syntax
bool setClipboard ( string theText )
Required Arguments
- theText: The new text to be in the players clipboard when the player pastes with CTRL + V.
Returns
Returns true if the text in the clip board was set correctly.
Example
This example adds a command called clipboard which lets you set your clipboard text.
addCommandHandler( "clipboard", -- add a command handler for the command function( command, ... ) local text = table.concat({...}, " ") -- if the text has spaces this will turn it into a string local success = setClipboard( text ) -- set the clipboard and find out if it worked if success then outputChatBox( "Clipboard text set to: " .. text, 0, 255, 0 ) -- if it did, tell the player else outputChatBox( "Failed to set the clipboards text", 255, 0, 0 ) -- if it didn't, tell the player end end )
This example is to allow you to copy the words that are written in edit box
window = guiCreateWindow(47, 105, 262, 56, "example By ProGamer", false) edit = guiCreateEdit(47, 105, 262, 56, "", false, window) button1 = guiCreateButton(58, 220, 234, 46, "copy", false, window) function clickedButton1() local text = guiGetText(edit) setClipboard(text) end addEventHandler("onClientGUIClick", button1, clickedButton1, false)
See Also
- createTrayNotification
- downloadFile
- getDevelopmentMode
- getKeyboardLayout
- getLocalization
- isShowCollisionsEnabled
- isShowSoundEnabled
- isTransferBoxAlwaysVisible
- isTransferBoxVisible
- isTrayNotificationEnabled
- setClipboard
- setDevelopmentMode
- setTransferBoxVisible
- setWindowFlashing
- showCol
- showSound
- Shared
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub
- bitAnd
- bitNot
- bitOr
- bitXor
- bitTest
- bitLRotate
- bitRRotate
- bitLShift
- bitRShift
- bitArShift
- bitExtract
- bitReplace