1 /**
2 A shortcut for binding input.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.shortcut;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.classdb;
23 import godot.resource;
24 import godot.inputevent;
25 import godot.reference;
26 /**
27 A shortcut for binding input.
28 
29 Shortcuts are commonly used for interacting with a $(D Control) element from a $(D InputEvent).
30 */
31 @GodotBaseClass struct ShortCut
32 {
33 	enum string _GODOT_internal_name = "ShortCut";
34 public:
35 @nogc nothrow:
36 	union { godot_object _godot_object; Resource _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct _classBinding
41 	{
42 		__gshared:
43 		@GodotName("set_shortcut") GodotMethod!(void, InputEvent) setShortcut;
44 		@GodotName("get_shortcut") GodotMethod!(InputEvent) getShortcut;
45 		@GodotName("is_valid") GodotMethod!(bool) isValid;
46 		@GodotName("is_shortcut") GodotMethod!(bool, InputEvent) isShortcut;
47 		@GodotName("get_as_text") GodotMethod!(String) getAsText;
48 	}
49 	bool opEquals(in ShortCut other) const { return _godot_object.ptr is other._godot_object.ptr; }
50 	ShortCut opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
51 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
52 	mixin baseCasts;
53 	static ShortCut _new()
54 	{
55 		static godot_class_constructor constructor;
56 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ShortCut");
57 		if(constructor is null) return typeof(this).init;
58 		return cast(ShortCut)(constructor());
59 	}
60 	@disable new(size_t s);
61 	/**
62 	
63 	*/
64 	void setShortcut(InputEvent event)
65 	{
66 		checkClassBinding!(typeof(this))();
67 		ptrcall!(void)(_classBinding.setShortcut, _godot_object, event);
68 	}
69 	/**
70 	
71 	*/
72 	Ref!InputEvent getShortcut() const
73 	{
74 		checkClassBinding!(typeof(this))();
75 		return ptrcall!(InputEvent)(_classBinding.getShortcut, _godot_object);
76 	}
77 	/**
78 	If `true` this shortcut is valid.
79 	*/
80 	bool isValid() const
81 	{
82 		checkClassBinding!(typeof(this))();
83 		return ptrcall!(bool)(_classBinding.isValid, _godot_object);
84 	}
85 	/**
86 	Returns `true` if the shortcut's $(D InputEvent) equals `event`.
87 	*/
88 	bool isShortcut(InputEvent event) const
89 	{
90 		checkClassBinding!(typeof(this))();
91 		return ptrcall!(bool)(_classBinding.isShortcut, _godot_object, event);
92 	}
93 	/**
94 	Returns the shortcut's $(D InputEvent) as a $(D String).
95 	*/
96 	String getAsText() const
97 	{
98 		checkClassBinding!(typeof(this))();
99 		return ptrcall!(String)(_classBinding.getAsText, _godot_object);
100 	}
101 	/**
102 	The shortcut's $(D InputEvent).
103 	Generally the $(D InputEvent) is a keyboard key, though it can be any $(D InputEvent).
104 	*/
105 	@property InputEvent shortcut()
106 	{
107 		return getShortcut();
108 	}
109 	/// ditto
110 	@property void shortcut(InputEvent v)
111 	{
112 		setShortcut(v);
113 	}
114 }