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 gtk.EventControllerFocus; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.EventController; 31 private import gtk.c.functions; 32 public import gtk.c.types; 33 private import std.algorithm; 34 35 36 /** 37 * `GtkEventControllerFocus` is an event controller to keep track of 38 * keyboard focus. 39 * 40 * The event controller offers [signal@Gtk.EventControllerFocus::enter] 41 * and [signal@Gtk.EventControllerFocus::leave] signals, as well as 42 * [property@Gtk.EventControllerFocus:is-focus] and 43 * [property@Gtk.EventControllerFocus:contains-focus] properties 44 * which are updated to reflect focus changes inside the widget hierarchy 45 * that is rooted at the controllers widget. 46 */ 47 public class EventControllerFocus : EventController 48 { 49 /** the main Gtk struct */ 50 protected GtkEventControllerFocus* gtkEventControllerFocus; 51 52 /** Get the main Gtk struct */ 53 public GtkEventControllerFocus* getEventControllerFocusStruct(bool transferOwnership = false) 54 { 55 if (transferOwnership) 56 ownedRef = false; 57 return gtkEventControllerFocus; 58 } 59 60 /** the main Gtk struct as a void* */ 61 protected override void* getStruct() 62 { 63 return cast(void*)gtkEventControllerFocus; 64 } 65 66 /** 67 * Sets our main struct and passes it to the parent class. 68 */ 69 public this (GtkEventControllerFocus* gtkEventControllerFocus, bool ownedRef = false) 70 { 71 this.gtkEventControllerFocus = gtkEventControllerFocus; 72 super(cast(GtkEventController*)gtkEventControllerFocus, ownedRef); 73 } 74 75 76 /** */ 77 public static GType getType() 78 { 79 return gtk_event_controller_focus_get_type(); 80 } 81 82 /** 83 * Creates a new event controller that will handle focus events. 84 * 85 * Returns: a new `GtkEventControllerFocus` 86 * 87 * Throws: ConstructionException GTK+ fails to create the object. 88 */ 89 public this() 90 { 91 auto __p = gtk_event_controller_focus_new(); 92 93 if(__p is null) 94 { 95 throw new ConstructionException("null returned by new"); 96 } 97 98 this(cast(GtkEventControllerFocus*) __p, true); 99 } 100 101 /** 102 * Returns %TRUE if focus is within @self or one of its children. 103 * 104 * Returns: %TRUE if focus is within @self or one of its children 105 */ 106 public bool containsFocus() 107 { 108 return gtk_event_controller_focus_contains_focus(gtkEventControllerFocus) != 0; 109 } 110 111 /** 112 * Returns %TRUE if focus is within @self, but not one of its children. 113 * 114 * Returns: %TRUE if focus is within @self, but not one of its children 115 */ 116 public bool isFocus() 117 { 118 return gtk_event_controller_focus_is_focus(gtkEventControllerFocus) != 0; 119 } 120 121 /** 122 * Emitted whenever the focus enters into the widget or one 123 * of its descendents. 124 * 125 * Note that this means you may not get an ::enter signal 126 * even though the widget becomes the focus location, in 127 * certain cases (such as when the focus moves from a descendent 128 * of the widget to the widget itself). If you are interested 129 * in these cases, you can monitor the 130 * [property@Gtk.EventControllerFocus:is-focus] 131 * property for changes. 132 */ 133 gulong addOnEnter(void delegate(EventControllerFocus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 134 { 135 return Signals.connect(this, "enter", dlg, connectFlags ^ ConnectFlags.SWAPPED); 136 } 137 138 /** 139 * Emitted whenever the focus leaves the widget hierarchy 140 * that is rooted at the widget that the controller is attached to. 141 * 142 * Note that this means you may not get a ::leave signal 143 * even though the focus moves away from the widget, in 144 * certain cases (such as when the focus moves from the widget 145 * to a descendent). If you are interested in these cases, you 146 * can monitor the [property@Gtk.EventControllerFocus:is-focus] 147 * property for changes. 148 */ 149 gulong addOnLeave(void delegate(EventControllerFocus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 150 { 151 return Signals.connect(this, "leave", dlg, connectFlags ^ ConnectFlags.SWAPPED); 152 } 153 }