1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-08-31 02:45:13 +00:00
Funkin/source/funkin/util/ClipboardUtil.hx
Hyper_ 88ed66affa chore: Add null safety to various utility and plugin classes
And add a bit of error handling to CharSelectGF & CharSelectSubState

Co-Authored-By: Linus Torvalds <torvalds@linux-foundation.org>
2025-06-23 14:13:35 -04:00

53 lines
1.5 KiB
Haxe

package funkin.util;
/**
* Utility functions for working with the system clipboard.
* On platforms that don't support interacting with the clipboard,
* an internal clipboard is used (neat!).
*/
@:nullSafety
class ClipboardUtil
{
/**
* Add an event listener callback which executes next time the system clipboard is updated.
*
* @param callback The callback to execute when the clipboard is updated.
* @param once If true, the callback will only execute once and then be deleted.
* @param priority Set the priority at which the callback will be executed. Higher values execute first.
*/
public static function addListener(callback:Void->Void, once:Bool = false, priority:Int = 0):Void
{
lime.system.Clipboard.onUpdate.add(callback, once, priority);
}
/**
* Remove an event listener callback from the system clipboard.
*
* @param callback The callback to remove.
*/
public static function removeListener(callback:Void->Void):Void
{
lime.system.Clipboard.onUpdate.remove(callback);
}
/**
* Get the current contents of the system clipboard.
*
* @return The current contents of the system clipboard.
*/
public static function getClipboard():String
{
return lime.system.Clipboard.text;
}
/**
* Set the contents of the system clipboard.
*
* @param text The text to set the system clipboard to.
*/
public static function setClipboard(text:String):String
{
return lime.system.Clipboard.text = text;
}
}