📄 z57.html
字号:
termed "ghosted" or "inactive"). </p> <p> <tt class="FUNCTION">gtk_widget_set_sensitive()</tt> (<a href="z57.html#FL-SETSENSITIVE">Figure 25</a>) changes a widget's sensitivity. </p> <div class="FIGURE"> <a name="FL-SETSENSITIVE"></a> <div class="FUNCSYNOPSIS"> <a name="FL-SETSENSITIVE.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO">#include <gtk/gtkwidget.h></pre> </td> </tr> </table> <p> <code><code class="FUNCDEF">void <tt class= "FUNCTION"> gtk_widget_set_sensitive</tt></code>(GtkWidget* <tt class="PARAMETER"><i>widget</i></tt>, gboolean <tt class="PARAMETER"><i>setting</i></tt>);</code> </p> </div> <p> <b>Figure 25. Changing Sensitivity</b> </p> </div> <p> By default sensitivity is set to <span class= "STRUCTNAME">TRUE</span>. A widget is only "really" sensitive if all its parents are sensitive; that is, you can make an entire container full of widgets (in)sensitive by setting the sensitivity of the container. The "real" sensitivity of a widget, including its parent's state, can be tested with the <tt class="FUNCTION">GTK_WIDGET_IS_SENSITIVE()</tt> macro. The sensitivity of the widget itself, which only matters if the widget's parent is sensitive, can be queried using <tt class="FUNCTION"> GTK_WIDGET_SENSITIVE()</tt>. These are in <a href= "z57.html#ML-ISSENSITIVE">Figure 26</a>. </p> <div class="FIGURE"> <a name="ML-ISSENSITIVE"></a> <div class="FUNCSYNOPSIS"> <a name="ML-ISSENSITIVE.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO">#include <gtk/gtkwidget.h></pre> </td> </tr> </table> <p> <code><code class="FUNCDEF"><tt class="FUNCTION"> GTK_WIDGET_IS_SENSITIVE</tt></code>(<tt class= "PARAMETER"><i>widget</i></tt>);</code> </p> <p> <code><code class="FUNCDEF"><tt class="FUNCTION"> GTK_WIDGET_SENSITIVE</tt></code>(<tt class= "PARAMETER"><i>widget</i></tt>);</code> </p> </div> <p> <b>Figure 26. Sensitivity</b> </p> </div> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="SEC-FOCUSWIDGET">Focus</a> </h3> <p> Within each toplevel window, one widget at a time may have the <i class="FIRSTTERM">keyboard focus</i>. Any key events received by the toplevel window are forwarded to the focused widget. This is important because typing something on the keyboard should have only one effect---changing only one text entry field, for example. </p> <p> Most widgets will give some visual indication that they have the current focus. Using the default GTK+ theme, the focused widget is typically surrounded by a thin black frame. The user can move the focus between widgets, using the arrow keys or the Tab key. Focus can also move to a widget if the user clicks it. </p> <p> The concept of focus is important for keyboard navigation. For example, pressing Enter or the space bar "activates" many widgets if they have the focus; you can move between buttons with the Tab key, and press one with Space, for example. </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="SEC-GRABS">Grabs</a> </h3> <p> Widgets can <i class="FIRSTTERM">grab</i> the pointer and keyboard away from other widgets. This essentially means that the widget becomes "modal"; input goes only to that widget, and the focus can't be changed to another widget. A typical reason to grab input is to create a modal dialog; if a window has the grab, interaction with other windows is blocked. Note that there is another, GDK-level "grab"; a GDK keyboard or pointer grab occurs on an X-server-wide basis---that is, other applications are unable to receive keyboard or mouse events. A widget grab is a GTK+ concept; it only grabs events away from other widgets in the same application. </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="Z59">Default</a> </h3> <p> Each window may have at most one <i class="FIRSTTERM"> default</i> widget. For example, dialogs typically have a default button which is activated when the user presses the Enter key. </p> </div> <div class="SECT3"> <h3 class="SECT3"> <a name="SEC-WIDGETSTATES">Widget States</a> </h3> <p> Widgets have <i class="FIRSTTERM">states</i> which determine their appearance: </p> <ul> <li> <p> <i class="FIRSTTERM">Normal</i>: just like it sounds. </p> </li> <li> <p> <i class="FIRSTTERM">Active</i>: a button is currently pressed in, or a check box is currently checked, for example. </p> </li> <li> <p> <i class="FIRSTTERM">Prelight</i>: the mouse is over the widget (and typically clicking would have some effect). Buttons "highlight" when you move over them, for example. </p> </li> <li> <p> <i class="FIRSTTERM">Selected</i>: the widget is in a list or other set of alternatives, and is the currently selected option. </p> </li> <li> <p> <i class="FIRSTTERM">Insensitive</i>: the widget is "ghosted," inactive, or unresponsive; it will not respond to input. </p> </li> </ul> <p> The exact meaning and visual representation of a given state depends on the particular widget and the current theme. You can access the state of the widget <tt class="FUNCTION">GTK_WIDGET_STATE()</tt> (<a href= "z57.html#ML-WIDGETSTATE">Figure 27</a>). This macro returns one of the constants <span class="STRUCTNAME"> GTK_STATE_NORMAL</span>, <span class="STRUCTNAME"> GTK_STATE_ACTIVE</span>, <span class="STRUCTNAME"> GTK_STATE_PRELIGHT</span>, <span class="STRUCTNAME"> GTK_STATE_SELECTED</span>, or <span class="STRUCTNAME"> GTK_STATE_INSENSITIVE</span>. </p> <div class="FIGURE"> <a name="ML-WIDGETSTATE"></a> <div class="FUNCSYNOPSIS"> <a name="ML-WIDGETSTATE.SYNOPSIS"></a> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="FUNCSYNOPSISINFO">#include <gtk/gtkwidget.h></pre> </td> </tr> </table> <p> <code><code class="FUNCDEF"><tt class="FUNCTION"> GTK_WIDGET_STATE</tt></code>(<tt class= "PARAMETER"><i>widget</i></tt>);</code> </p> </div> <p> <b>Figure 27. State Accessor</b> </p> </div> </div> </div> </div> <div class="NAVFOOTER"> <br> <br> <table width="100%" border="0" bgcolor="#ffffff" cellpadding= "1" cellspacing="0"> <tr> <td width="25%" bgcolor="#ffffff" align="left"> <a href="sec-containers.html"><font color="#0000ff" size="2"><b><<< Previous</b></font></a> </td> <td width="25%" colspan="2" bgcolor="#ffffff" align= "center"> <font color="#0000ff" size="2"><b><a href="ggad.html"> <font color="#0000ff" size="2"><b> Home</b></font></a></b></font> </td> <td width="25%" bgcolor="#ffffff" align="right"> <a href="sec-mainloop.html"><font color="#0000ff" size= "2"><b>Next >>></b></font></a> </td> </tr> <tr> <td colspan="2" align="left"> <font color="#000000" size="2"><b>Containers And Widget Layout</b></font> </td> <td colspan="2" align="right"> <font color="#000000" size="2"><b>The Main Loop</b></font> </td> </tr> </table> </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -