1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gdk.KeyEvent; 26 27 private import gdk.Event; 28 private import gdk.c.functions; 29 public import gdk.c.types; 30 31 32 /** 33 * An event related to a key-based device. 34 */ 35 public class KeyEvent : Event 36 { 37 /** the main Gtk struct */ 38 protected GdkKeyEvent* gdkKeyEvent; 39 40 /** Get the main Gtk struct */ 41 public GdkKeyEvent* getKeyEventStruct(bool transferOwnership = false) 42 { 43 if (transferOwnership) 44 ownedRef = false; 45 return gdkKeyEvent; 46 } 47 48 /** the main Gtk struct as a void* */ 49 protected override void* getStruct() 50 { 51 return cast(void*)gdkKeyEvent; 52 } 53 54 /** 55 * Sets our main struct and passes it to the parent class. 56 */ 57 public this (GdkKeyEvent* gdkKeyEvent, bool ownedRef = false) 58 { 59 this.gdkKeyEvent = gdkKeyEvent; 60 super(cast(GdkEvent*)gdkKeyEvent, ownedRef); 61 } 62 63 64 /** */ 65 public static GType getType() 66 { 67 return gdk_key_event_get_type(); 68 } 69 70 /** 71 * Extracts the consumed modifiers from a key event. 72 * 73 * Returns: the consumed modifiers or @event 74 */ 75 public GdkModifierType getConsumedModifiers() 76 { 77 return gdk_key_event_get_consumed_modifiers(cast(GdkEvent*)gdkKeyEvent); 78 } 79 80 /** 81 * Extracts the keycode from a key event. 82 * 83 * Returns: the keycode of @event 84 */ 85 public uint getKeycode() 86 { 87 return gdk_key_event_get_keycode(cast(GdkEvent*)gdkKeyEvent); 88 } 89 90 /** 91 * Extracts the keyval from a key event. 92 * 93 * Returns: the keyval of @event 94 */ 95 public uint getKeyval() 96 { 97 return gdk_key_event_get_keyval(cast(GdkEvent*)gdkKeyEvent); 98 } 99 100 /** 101 * Extracts the layout from a key event. 102 * 103 * Returns: the layout of @event 104 */ 105 public uint getLayout() 106 { 107 return gdk_key_event_get_layout(cast(GdkEvent*)gdkKeyEvent); 108 } 109 110 /** 111 * Extracts the shift level from a key event. 112 * 113 * Returns: the shift level of @event 114 */ 115 public uint getLevel() 116 { 117 return gdk_key_event_get_level(cast(GdkEvent*)gdkKeyEvent); 118 } 119 120 /** 121 * Gets a keyval and modifier combination that will match 122 * the event. 123 * 124 * See [method@Gdk.KeyEvent.matches]. 125 * 126 * Params: 127 * keyval = return location for a keyval 128 * modifiers = return location for modifiers 129 * 130 * Returns: %TRUE on success 131 */ 132 public bool getMatch(out uint keyval, out GdkModifierType modifiers) 133 { 134 return gdk_key_event_get_match(cast(GdkEvent*)gdkKeyEvent, &keyval, &modifiers) != 0; 135 } 136 137 /** 138 * Extracts whether the key event is for a modifier key. 139 * 140 * Returns: %TRUE if the @event is for a modifier key 141 */ 142 public bool isModifier() 143 { 144 return gdk_key_event_is_modifier(cast(GdkEvent*)gdkKeyEvent) != 0; 145 } 146 147 /** 148 * Matches a key event against a keyval and modifiers. 149 * 150 * This is typically used to trigger keyboard shortcuts such as Ctrl-C. 151 * 152 * Partial matches are possible where the combination matches 153 * if the currently active group is ignored. 154 * 155 * Note that we ignore Caps Lock for matching. 156 * 157 * Params: 158 * keyval = the keyval to match 159 * modifiers = the modifiers to match 160 * 161 * Returns: a `GdkKeyMatch` value describing whether @event matches 162 */ 163 public GdkKeyMatch matches(uint keyval, GdkModifierType modifiers) 164 { 165 return gdk_key_event_matches(cast(GdkEvent*)gdkKeyEvent, keyval, modifiers); 166 } 167 }