1 /** 2 Base class for keys events with modifiers. 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.inputeventwithmodifiers; 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.inputevent; 24 import godot.resource; 25 /** 26 Base class for keys events with modifiers. 27 28 Contains keys events information with modifiers support like `Shift` or `Alt`. See $(D Node._input). 29 */ 30 @GodotBaseClass struct InputEventWithModifiers 31 { 32 package(godot) enum string _GODOT_internal_name = "InputEventWithModifiers"; 33 public: 34 @nogc nothrow: 35 union { /** */ godot_object _godot_object; /** */ InputEvent _GODOT_base; } 36 alias _GODOT_base this; 37 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 38 package(godot) __gshared bool _classBindingInitialized = false; 39 package(godot) static struct GDNativeClassBinding 40 { 41 __gshared: 42 @GodotName("get_alt") GodotMethod!(bool) getAlt; 43 @GodotName("get_command") GodotMethod!(bool) getCommand; 44 @GodotName("get_control") GodotMethod!(bool) getControl; 45 @GodotName("get_metakey") GodotMethod!(bool) getMetakey; 46 @GodotName("get_shift") GodotMethod!(bool) getShift; 47 @GodotName("set_alt") GodotMethod!(void, bool) setAlt; 48 @GodotName("set_command") GodotMethod!(void, bool) setCommand; 49 @GodotName("set_control") GodotMethod!(void, bool) setControl; 50 @GodotName("set_metakey") GodotMethod!(void, bool) setMetakey; 51 @GodotName("set_shift") GodotMethod!(void, bool) setShift; 52 } 53 /// 54 pragma(inline, true) bool opEquals(in InputEventWithModifiers other) const 55 { return _godot_object.ptr is other._godot_object.ptr; } 56 /// 57 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 58 { _godot_object.ptr = n; return null; } 59 /// 60 pragma(inline, true) bool opEquals(typeof(null) n) const 61 { return _godot_object.ptr is n; } 62 /// 63 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 64 mixin baseCasts; 65 /// Construct a new instance of InputEventWithModifiers. 66 /// Note: use `memnew!InputEventWithModifiers` instead. 67 static InputEventWithModifiers _new() 68 { 69 static godot_class_constructor constructor; 70 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("InputEventWithModifiers"); 71 if(constructor is null) return typeof(this).init; 72 return cast(InputEventWithModifiers)(constructor()); 73 } 74 @disable new(size_t s); 75 /** 76 77 */ 78 bool getAlt() const 79 { 80 checkClassBinding!(typeof(this))(); 81 return ptrcall!(bool)(GDNativeClassBinding.getAlt, _godot_object); 82 } 83 /** 84 85 */ 86 bool getCommand() const 87 { 88 checkClassBinding!(typeof(this))(); 89 return ptrcall!(bool)(GDNativeClassBinding.getCommand, _godot_object); 90 } 91 /** 92 93 */ 94 bool getControl() const 95 { 96 checkClassBinding!(typeof(this))(); 97 return ptrcall!(bool)(GDNativeClassBinding.getControl, _godot_object); 98 } 99 /** 100 101 */ 102 bool getMetakey() const 103 { 104 checkClassBinding!(typeof(this))(); 105 return ptrcall!(bool)(GDNativeClassBinding.getMetakey, _godot_object); 106 } 107 /** 108 109 */ 110 bool getShift() const 111 { 112 checkClassBinding!(typeof(this))(); 113 return ptrcall!(bool)(GDNativeClassBinding.getShift, _godot_object); 114 } 115 /** 116 117 */ 118 void setAlt(in bool enable) 119 { 120 checkClassBinding!(typeof(this))(); 121 ptrcall!(void)(GDNativeClassBinding.setAlt, _godot_object, enable); 122 } 123 /** 124 125 */ 126 void setCommand(in bool enable) 127 { 128 checkClassBinding!(typeof(this))(); 129 ptrcall!(void)(GDNativeClassBinding.setCommand, _godot_object, enable); 130 } 131 /** 132 133 */ 134 void setControl(in bool enable) 135 { 136 checkClassBinding!(typeof(this))(); 137 ptrcall!(void)(GDNativeClassBinding.setControl, _godot_object, enable); 138 } 139 /** 140 141 */ 142 void setMetakey(in bool enable) 143 { 144 checkClassBinding!(typeof(this))(); 145 ptrcall!(void)(GDNativeClassBinding.setMetakey, _godot_object, enable); 146 } 147 /** 148 149 */ 150 void setShift(in bool enable) 151 { 152 checkClassBinding!(typeof(this))(); 153 ptrcall!(void)(GDNativeClassBinding.setShift, _godot_object, enable); 154 } 155 /** 156 State of the `Alt` modifier. 157 */ 158 @property bool alt() 159 { 160 return getAlt(); 161 } 162 /// ditto 163 @property void alt(bool v) 164 { 165 setAlt(v); 166 } 167 /** 168 State of the `Command` modifier. 169 */ 170 @property bool command() 171 { 172 return getCommand(); 173 } 174 /// ditto 175 @property void command(bool v) 176 { 177 setCommand(v); 178 } 179 /** 180 State of the `Ctrl` modifier. 181 */ 182 @property bool control() 183 { 184 return getControl(); 185 } 186 /// ditto 187 @property void control(bool v) 188 { 189 setControl(v); 190 } 191 /** 192 State of the `Meta` modifier. 193 */ 194 @property bool meta() 195 { 196 return getMetakey(); 197 } 198 /// ditto 199 @property void meta(bool v) 200 { 201 setMetakey(v); 202 } 203 /** 204 State of the `Shift` modifier. 205 */ 206 @property bool shift() 207 { 208 return getShift(); 209 } 210 /// ditto 211 @property void shift(bool v) 212 { 213 setShift(v); 214 } 215 }