Files
CodenameEngine/source/funkin/scripting/events/CancellableEvent.hx
T
2022-10-09 23:21:25 +02:00

38 lines
1006 B
Haxe

package funkin.scripting.events;
import funkin.scripting.ScriptPack;
@:allow(ScriptPack)
class CancellableEvent {
@:dox(hide) public var cancelled:Bool = false;
@:dox(hide) private var __continueCalls:Bool = true;
/**
* Additional data if used in scripts
*/
public var data:Dynamic = {};
/**
* Prevents default action from occuring.
* @param c Whenever the scripts following this one should be called or not. (Defaults to `true`)
*/
public function preventDefault(c:Bool = true) {
cancelled = true;
__continueCalls = c;
}
@:dox(hide)
public function cancel(c:Bool = true) {preventDefault(c);}
/**
* Creates a new cancellable event.
* This allows scripts to call `cancel()` to cancel the event.
*/
public function new() {}
public function toString():String {
var rep = '[CancellableEvent ${cancelled ? "(Cancelled)" : ""} - ]';
// TODO: List all fields
return rep;
}
}