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.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.resource;
25 import godot.reference;
26 import godot.inputevent;
27 /**
28 A shortcut for binding input.
29 
30 Shortcuts are commonly used for interacting with a $(D Control) element from a $(D InputEvent).
31 */
32 @GodotBaseClass struct ShortCut
33 {
34 	package(godot) enum string _GODOT_internal_name = "ShortCut";
35 public:
36 @nogc nothrow:
37 	union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct GDNativeClassBinding
42 	{
43 		__gshared:
44 		@GodotName("get_as_text") GodotMethod!(String) getAsText;
45 		@GodotName("get_shortcut") GodotMethod!(InputEvent) getShortcut;
46 		@GodotName("is_shortcut") GodotMethod!(bool, InputEvent) isShortcut;
47 		@GodotName("is_valid") GodotMethod!(bool) isValid;
48 		@GodotName("set_shortcut") GodotMethod!(void, InputEvent) setShortcut;
49 	}
50 	/// 
51 	pragma(inline, true) bool opEquals(in ShortCut other) const
52 	{ return _godot_object.ptr is other._godot_object.ptr; }
53 	/// 
54 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
55 	{ _godot_object.ptr = n; return null; }
56 	/// 
57 	pragma(inline, true) bool opEquals(typeof(null) n) const
58 	{ return _godot_object.ptr is n; }
59 	/// 
60 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
61 	mixin baseCasts;
62 	/// Construct a new instance of ShortCut.
63 	/// Note: use `memnew!ShortCut` instead.
64 	static ShortCut _new()
65 	{
66 		static godot_class_constructor constructor;
67 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ShortCut");
68 		if(constructor is null) return typeof(this).init;
69 		return cast(ShortCut)(constructor());
70 	}
71 	@disable new(size_t s);
72 	/**
73 	Returns the shortcut's $(D InputEvent) as a $(D String).
74 	*/
75 	String getAsText() const
76 	{
77 		checkClassBinding!(typeof(this))();
78 		return ptrcall!(String)(GDNativeClassBinding.getAsText, _godot_object);
79 	}
80 	/**
81 	
82 	*/
83 	Ref!InputEvent getShortcut() const
84 	{
85 		checkClassBinding!(typeof(this))();
86 		return ptrcall!(InputEvent)(GDNativeClassBinding.getShortcut, _godot_object);
87 	}
88 	/**
89 	Returns `true` if the shortcut's $(D InputEvent) equals `event`.
90 	*/
91 	bool isShortcut(InputEvent event) const
92 	{
93 		checkClassBinding!(typeof(this))();
94 		return ptrcall!(bool)(GDNativeClassBinding.isShortcut, _godot_object, event);
95 	}
96 	/**
97 	If `true`, this shortcut is valid.
98 	*/
99 	bool isValid() const
100 	{
101 		checkClassBinding!(typeof(this))();
102 		return ptrcall!(bool)(GDNativeClassBinding.isValid, _godot_object);
103 	}
104 	/**
105 	
106 	*/
107 	void setShortcut(InputEvent event)
108 	{
109 		checkClassBinding!(typeof(this))();
110 		ptrcall!(void)(GDNativeClassBinding.setShortcut, _godot_object, event);
111 	}
112 	/**
113 	The shortcut's $(D InputEvent).
114 	Generally the $(D InputEvent) is a keyboard key, though it can be any $(D InputEvent).
115 	*/
116 	@property InputEvent shortcut()
117 	{
118 		return getShortcut();
119 	}
120 	/// ditto
121 	@property void shortcut(InputEvent v)
122 	{
123 		setShortcut(v);
124 	}
125 }