{"id":90,"date":"2014-04-03T09:46:40","date_gmt":"2014-04-03T09:46:40","guid":{"rendered":""},"modified":"2014-04-03T09:46:40","modified_gmt":"2014-04-03T09:46:40","slug":"","status":"publish","type":"post","link":"http:\/\/weizn.net\/?p=90","title":{"rendered":"[\u8f6c]GTK \u4e8b\u4ef6"},"content":{"rendered":"<p>&nbsp; &nbsp; &nbsp; \u4e8b\u4ef6\u662f\u7531X Window\u7cfb\u7edf\u53d1\u51fa\u7684\u7279\u6b8a\u7c7b\u578b\u7684\u4fe1\u53f7\u3002 \u5b83\u4eec\u6700\u521d\u7531X<br \/>\nWindow\u7cfb\u7edf\u53d1\u51fa\uff0c\u7136\u540e\u7531\u7a97\u53e3\u7ba1\u7406\u5668\u53d1\u7ed9\u60a8\u7684\u7a0b\u5e8f\uff0cGLib\u63d0\u4f9b\u7684\u4fe1\u53f7\u7cfb\u7edf\u5c31\u4f1a\u4e2d\u65ad\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0cdestroy\u4fe1\u53f7\u7531\u6784\u4ef6\u53d1\u51fa\uff0c\u4f46\u662fdelete-<br \/>\nevent\u4e8b\u4ef6\u6700\u521d\u7531\u6784\u4ef6\u4e0b\u5c42\u7684GdkWindow\u8bc6\u522b\u51fa\u6765\uff0c\u7136\u540e\u53d1\u51fa\u4e00\u4e2a\u4fe1\u53f7\u7ed9\u6784\u4ef6\u3002<\/p>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u5b8c\u6210\u201c\u8fde\u63a5\u4e8b\u4ef6\u548c\u56de\u8c03\u51fd\u6570\u201d\u91c7\u7528\u4e86\u548c\u201c<span style=\"line-height:22px;\">g_signal_connect()\u8fde\u63a5GTK+\u4fe1\u53f7<\/span>\u201d\u5dee\u4e0d\u591a\u4e00\u6837\u7684\u65b9\u5f0f\u3002\u7136\u800c\uff0c\u60a8\u7684\u56de\u8c03\u51fd\u6570\u7565\u6709\u4e0d\u540c\u3002\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; static gboolean<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; callback_function (GtkWidget *widget,<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GdkEvent *event,<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gpointer data);<\/i>\n\t<\/div>\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n\t&nbsp;<br \/>\n &nbsp; &nbsp; &nbsp;<br \/>\n\u7b2c\u4e00\u4e2a\u4e0d\u540c\u7684\u5730\u65b9\u662f\u56de\u8c03\u51fd\u6570\u4f7f\u7528gboolean\u4f5c\u4e3a\u8fd4\u56de\u503c\u3002\u5982\u679c\u4e8b\u4ef6\u56de\u8c03\u51fd\u6570\u8fd4\u56deTRUE\uff0cGTK+\u8ba4\u4e3a\u4e8b\u4ef6\u5df2\u7ecf\u88ab\u5904\u7406\u5b8c\u4e86\uff0c\u5b83\u4e0d\u4f1a\u7ee7\u7eed\u5904\u7406\u3002\u901a\u8fc7\u8fd4\u56de<br \/>\nFALSE\uff0c\u60a8\u901a\u77e5GTK+\u7ee7\u7eed\u5904\u7406\u8be5\u4e8b\u4ef6\u3002FALSE\u662f\u51fd\u6570\u9ed8\u8ba4\u7684\u8fd4\u56de\u503c\uff0c\u56e0\u4e3a\u591a\u6570\u60c5\u51b5\u4e0b\u60a8\u4e0d\u7528\u4f7f\u7528delete-event\u4fe1\u53f7\u3002\u8fd9\u53ea\u5728\u4e00\u79cd\u60c5\u51b5\u4e0b\u6709<br \/>\n\u6548\uff0c\u5c31\u662f\u60a8\u60f3\u91cd\u8f7d\u9ed8\u8ba4\u7684\u4fe1\u53f7\u5904\u7406\u51fd\u6570\u3002\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u4e3e\u4f8b\u6765\u8bf4\uff0c\u5728\u8bb8\u591a\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u60a8\u4e5f\u8bb8\u9700\u8981\u786e\u8ba4\u7a0b\u5e8f\u9000\u51fa\u3002\u901a\u8fc7\u4f7f\u7528\u4e0b\u8ff0\u4ee3\u7801\uff0c\u60a8\u53ef\u4ee5\u9632\u6b62\u7a0b\u5e8f\u610f\u5916\u9000\u51fa\u3002\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n<div>\n\t\t&nbsp; &nbsp; &nbsp; &nbsp; <i>static gboolean<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; delete_event (GtkWidget *window,<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GdkEvent *event,<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gpointer data)<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; {<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gboolean answer = \/* Ask the user if exiting is desired. *\/<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (answer)<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return FALSE;<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return TRUE;<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; }<\/i>\n\t<\/div>\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n\t<span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp; \u901a\u8fc7\u5728delete-event\u56de\u8c03\u51fd\u6570\u4e2d\u8fd4\u56deFALSE\uff0c\u6784\u4ef6\u81ea\u52a8\u8c03\u7528gtk_widget_destroy()\u3002\u6b63\u5982\u4ee5\u524d\u6240\u8ff0\uff0c\u4fe1\u53f7\u548c\u52a8\u4f5c\u662f\u81ea\u52a8\u5173\u8054\u7684\uff0c\u56e0\u6b64\u60a8\u4e0d\u7528\u7f16\u7a0b\u8fde\u63a5\u5b83\uff0c\u9664\u975e\u60a8\u8981\u4fee\u6539\u9ed8\u8ba4\u7684\u4e1c\u897f\u3002<\/span>\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style=\"line-height:22px;\">&nbsp;<\/span><span style=\"line-height:22px;\">\u9664\u6b64\u4e4b\u5916\uff0c\u56de\u8c03\u51fd\u6570\u5305\u62ecGdkEvent\u53c2\u6570\u3002GdkEvent\u662f\u4e2aC\u8054\u5408\u4f53\uff0c\u5305\u542bGdkEventType\u679a\u4e3e\u548c\u6240\u6709\u4e8b\u4ef6\u7ed3\u6784\u3002\u8ba9\u6211\u4eec\u770b\u4e00\u773cGdkEventType\u679a\u4e3e\u3002<\/span>\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n\t<b><span style=\"font-size:medium;\">\u4e8b\u4ef6\u7c7b\u578b<\/span><\/b>\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; GdkEventType\u679a\u4e3e\u7c7b\u578b\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6709\u6548\u7684\u4e8b\u4ef6\u7c7b\u578b\u7684\u961f\u5217\u3002\u4ed6\u4eec\u53ef\u4ee5\u7528\u4e8e\u5224\u65ad\u53d1\u751f\u4e8b\u4ef6\u7684\u7c7b\u578b\uff0c\u6bd5\u7adf\u4f60\u4e0d\u662f\u603b\u6e05\u695a\u53d1\u751f\u4e86\u4ec0\u4e48\u3002\n<\/div>\n<div>\n\t&nbsp;<br \/>\n &nbsp; &nbsp; &nbsp;<br \/>\n\u4e3e\u4f8b\u6765\u8bf4\uff0c\u5982\u679c\u60a8\u628abutton-press-event\u4fe1\u53f7\u8fde\u63a5\u5230\u4e86\u4e00\u4e2a\u6784\u4ef6\uff0c\u4fe1\u53f7\u56de\u8c03\u51fd\u6570\u5c31\u6709\u53ef\u80fd\u6536\u52303\u4e2d\u4e0d\u540c\u7c7b\u578b\u7684\u4e8b<br \/>\n\u4ef6\uff1aGDK_BUTTON_PRESS\u3001GDK_2BUTTON_PRESS\u548cGDK_3BUTTON_PRESS\u3002\u53cc\u51fb\u6216\u8005\u4e09\u51fb\u6784\u4ef6\uff0c\u4e5f\u80fd\u89e6\u53d1<br \/>\nGDK_BUTTON_PRESS\uff0c\u4e0d\u8fc7\u4f5c\u4e3a\u7b2c\u4e8c\u6761\u4e8b\u4ef6\uff0c\u56e0\u6b64\u80fd\u591f\u533a\u5206\u51fa\u4e0d\u540c\u7684\u4e8b\u4ef6\u7c7b\u578b\u662f\u5fc5\u8981\u7684\u3002\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u5728\u9644\u5f55B\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u4e00\u4e2a\u5b8c\u6574\u5217\u8868\uff0c\u5305\u62ec\u6240\u6709\u6709\u6548\u5730\u4e8b\u4ef6\u3002\u5b83\u63d0\u4f9b\u4e86\u4fe1\u53f7\u540d\uff0c\u53ef\u4ee5\u4f20\u9012\u7ed9g_signal_connect()\uff0c\u8fd8\u63d0\u4f9b\u4e86GdkEventType\u679a\u4e3e\u503c\u548c\u4e8b\u4ef6\u7684\u63cf\u8ff0\u3002\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u8ba9\u6211\u4eec\u56de\u5934\u518d\u770b\u770bListing 2-2\u4e2d\u7684delete-event\u56de\u8c03\u51fd\u6570\u3002\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u4e86delete-event\u7684\u679a\u4e3e\u503c\u662fGDK_DELETE\uff0c\u4f46\u662f\u6211\u4eec\u5047\u5b9a\u5728\u67d0\u4e2a\u65f6\u523b\u6211\u4eec\u4e0d\u77e5\u9053\u3002\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u4e0b\u5217\u4ee3\u7801\u6d4b\u8bd5\u51fa\u6765\uff1a\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n<div>\n\t\t<span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp;<\/span><i>static gboolean<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp;<\/span>delete_event (GtkWidget *window,<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/span>GdkEvent *event,<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp;<\/span>gpointer data)<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp;<\/span>{<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp;<\/span>if (event-&gt;type == GDK_DELETE)<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp;<\/span>return FALSE;<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp;<\/span>return TRUE;<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp;<\/span>}<\/i>\n\t<\/div>\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5982\u679c\u4e8b\u4ef6\u7c7b\u578b\u662fGDK_DELETE\uff0c\u5219\u8fd4\u56deFALSE\uff0c\u8fd9\u6837\u6784\u4ef6\u5c31\u4f1a\u8c03\u7528gtk_widget_destroy()\u3002\u5426\u5219\uff0c\u8fd4\u56deTRUE\uff0c\u5c31\u4e0d\u4f1a\u6709\u540e\u9762\u7684\u52a8\u4f5c\u4e86\u3002\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n\t<span style=\"font-size:medium;\"><b>\u4f7f\u7528\u7279\u5b9a\u7684\u4e8b\u4ef6\u7ed3\u6784<\/b><\/span>\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u6709\u65f6\u5019\uff0c\u60a8\u4e5f\u8bb8\u5df2\u7ecf\u6e05\u695a\u53d1\u51fa\u7684\u4e8b\u4ef6\u7c7b\u578b\u4e86\u3002\u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u77e5\u9053\u4e00\u5b9a\u53d1\u51fa\u7684\u662fkey-press-event\u3002\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; g_signal_connect (G_OBJECT (widget), &#8220;key-press-event&#8221;<\/i>\n\t<\/div>\n<div>\n\t\t<i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;G_CALLBACK (key_press), NULL);<\/i>\n\t<\/div>\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u5047\u5b9a\u4e8b\u4ef6\u7c7b\u578b\u4e00\u5b9a\u662fGDK_KEY_PRESS\uff0c\u8fd9\u662f\u5b89\u5168\u7684\uff0c\u56de\u8c03\u51fd\u6570\u53ef\u4ee5\u58f0\u660e\u6210\u5982\u4e0b\u6240\u793a\u3002\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n<div>\n\t\t&nbsp; &nbsp; &nbsp; &nbsp; static gboolean\n\t<\/div>\n<div>\n\t\t<span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp;<\/span>key_press (GtkWidget *widget,\n\t<\/div>\n<div>\n\t\t<span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/span>GdkEventKey *event,\n\t<\/div>\n<div>\n\t\t<span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/span><span style=\"line-height:22px;\">&nbsp;<\/span>gpointer data)\n\t<\/div>\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n\t&nbsp;<br \/>\n &nbsp; &nbsp; &nbsp;<br \/>\n\u65e2\u7136\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u4e86\u4e8b\u4ef6\u7c7b\u578b\u662fGDK_KEY_PRESS\uff0c\u6211\u4eec\u5c31\u4e0d\u9700\u8981\u8bbf\u95eeGdkEvnet\u4e2d\u7684\u6240\u6709\u7ed3\u6784\u4e86\u3002\u5728\u56de\u8c03\u51fd\u6570\u4e2d\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528<br \/>\nGdkEventKey\uff0c\u800c\u4e0d\u9700\u8981GdkEvent\u4e86\u3002\u65e2\u7136\u7c7b\u578b\u5df2\u7ecf\u88ab\u8f6c\u6362\u6210\u4e3aGdkEventKey\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u8be5\u7ed3\u6784\u7684\u6210\u5458\u3002\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n<div>\n\t\t<i><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span>typedef struct<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span>{<\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span>GdkEventType type;<span style=\"color:#99cc00;\"> \/\/ GDK_KEY_PRESS or GDK_KEY_RELEASE<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span>GdkWindow *window; <span style=\"color:#99cc00;\">\/\/ The window that received the event<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;<\/span><\/span>gint8 send_event;<span style=\"color:#99cc00;\"> \/\/ TRUE if the event used XSendEvent<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span>guint32 time; <span style=\"color:#99cc00;\">\/\/ The length of the event in milliseconds<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span>guint state; <span style=\"color:#99cc00;\">\/\/ The state of Control, Shift, and Alt<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;<\/span><\/span>guint keyval;<span style=\"color:#99cc00;\"> \/\/ The key that was pressed &lt;gdk\/gdkkeysyms.h&gt;<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span>gint length; <span style=\"color:#99cc00;\">\/\/ The length of string<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span>gchar *string; <span style=\"color:#99cc00;\">\/\/ A string approximating the entered text<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;<\/span><\/span>guint16 hardware_keycode;<span style=\"color:#99cc00;\"> \/\/ Raw code of the key that was pressed or released<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span>guint8 group;<span style=\"color:#99cc00;\"> \/\/ The keyboard group<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp;&nbsp;<\/span><\/span><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span>guint is_modifier : 1;<span style=\"color:#99cc00;\"> \/\/ Whether hardware_keycode was mapped (since 2.10)<\/span><\/i>\n\t<\/div>\n<div>\n\t\t<i><span style=\"line-height:22px;\"><span style=\"line-height:22px;\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/span>} GdkEventKey;<\/i>\n\t<\/div>\n<\/div>\n<div>\n\t\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u5728<span style=\"line-height:22px;\">GdkEventKey\u7ed3\u6784\u4e2d\uff0c<\/span>\u6709\u8bb8\u591a\u6709\u7528\u7684\u5c5e\u6027\uff0c\u8fd9\u4e9b\u5185\u5bb9\u8d2f\u7a7f\u672c\u4e66\u3002\u5bf9\u60a8\u6765\u8bf4\uff0c\u9700\u8981\u7684\u65f6\u5019\u67e5\u9605\u5173\u4e8eGdkEvent\u7ed3\u6784\u7684API\u6587\u6863\uff0c\u6709\u5f88\u5927\u5e2e\u52a9\u3002\u672c\u4e66\u6211\u4eec\u53ea\u80fd\u8986\u76d6\u5c11\u6570\u6700\u91cd\u8981\u7684\u7ed3\u6784\uff0c\u5305\u62ecGdkEventKey\u548cGdkEventButton\u3002\n<\/div>\n<div>\n\t&nbsp; &nbsp; &nbsp; &nbsp; \u5728\u6240\u6709\u4e8b\u4ef6\u7ed3\u6784\u4e2d\uff0c\u4e8b\u4ef6\u7c7b\u578b\u662f\u90fd\u6709\u7684\u6210\u5458\u53d8\u91cf\uff0c\u5b83\u5b9a\u4e49\u4e86\u6b63\u5728\u53d1\u751f\u7684\u4e8b\u4ef6\u7684\u7c7b\u578b\u3002\u59cb\u7ec8\u68c0\u67e5\u4e8b\u4ef6\u7c7b\u578b\u662f\u4e2a\u597d\u4e60\u60ef\uff0c\u9632\u6b62\u60a8\u610f\u5916\u51fa\u9519\u3002\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; &nbsp; \u4e8b\u4ef6\u662f\u7531X Window\u7cfb\u7edf\u53d1\u51fa\u7684\u7279\u6b8a\u7c7b\u578b\u7684\u4fe1\u53f7\u3002 \u5b83\u4eec\u6700\u521d\u7531X<br \/>\nWindow\u7cfb\u7edf\u53d1\u51fa\uff0c\u7136\u540e\u7531\u7a97\u53e3\u7ba1\u7406\u5668\u53d1\u7ed9\u60a8\u7684\u7a0b\u5e8f\uff0cGLib\u63d0\u4f9b\u7684\u4fe1\u53f7\u7cfb\u7edf\u5c31\u4f1a\u4e2d\u65ad\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0cdestroy\u4fe1\u53f7\u7531\u6784\u4ef6\u53d1\u51fa\uff0c\u4f46\u662fdelete-<br \/>\nevent\u4e8b\u4ef6\u6700\u521d\u7531\u6784\u4ef6\u4e0b\u5c42\u7684GdkWindow\u8bc6\u522b\u51fa\u6765\uff0c\u7136\u540e\u53d1\u51fa\u4e00\u4e2a\u4fe1\u53f7\u7ed9\u6784\u4ef6\u3002<\/p>\n<div>\n\t&nbsp; &nbsp; &nbsp; &#038;nbs&#8230;<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[327],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[\u8f6c]GTK \u4e8b\u4ef6 - Wayne&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/weizn.net\/?p=90\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[\u8f6c]GTK \u4e8b\u4ef6 - Wayne&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"&nbsp; &nbsp; &nbsp; \u4e8b\u4ef6\u662f\u7531X Window\u7cfb\u7edf\u53d1\u51fa\u7684\u7279\u6b8a\u7c7b\u578b\u7684\u4fe1\u53f7\u3002 \u5b83\u4eec\u6700\u521d\u7531X  Window\u7cfb\u7edf\u53d1\u51fa\uff0c\u7136\u540e\u7531\u7a97\u53e3\u7ba1\u7406\u5668\u53d1\u7ed9\u60a8\u7684\u7a0b\u5e8f\uff0cGLib\u63d0\u4f9b\u7684\u4fe1\u53f7\u7cfb\u7edf\u5c31\u4f1a\u4e2d\u65ad\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0cdestroy\u4fe1\u53f7\u7531\u6784\u4ef6\u53d1\u51fa\uff0c\u4f46\u662fdelete- event\u4e8b\u4ef6\u6700\u521d\u7531\u6784\u4ef6\u4e0b\u5c42\u7684GdkWindow\u8bc6\u522b\u51fa\u6765\uff0c\u7136\u540e\u53d1\u51fa\u4e00\u4e2a\u4fe1\u53f7\u7ed9\u6784\u4ef6\u3002   &nbsp; &nbsp; &nbsp; &amp;nbs...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/weizn.net\/?p=90\" \/>\n<meta property=\"og:site_name\" content=\"Wayne&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-04-03T09:46:40+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"zinan\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/weizn.net\/#website\",\"url\":\"http:\/\/weizn.net\/\",\"name\":\"Wayne&#039;s Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/weizn.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/weizn.net\/?p=90#webpage\",\"url\":\"http:\/\/weizn.net\/?p=90\",\"name\":\"[\\u8f6c]GTK \\u4e8b\\u4ef6 - Wayne&#039;s Blog\",\"isPartOf\":{\"@id\":\"http:\/\/weizn.net\/#website\"},\"datePublished\":\"2014-04-03T09:46:40+00:00\",\"dateModified\":\"2014-04-03T09:46:40+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/weizn.net\/?p=90#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/weizn.net\/?p=90\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/weizn.net\/?p=90#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\\u9996\\u9875\",\"item\":\"http:\/\/weizn.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[\\u8f6c]GTK \\u4e8b\\u4ef6\"}]},{\"@type\":\"Article\",\"@id\":\"http:\/\/weizn.net\/?p=90#article\",\"isPartOf\":{\"@id\":\"http:\/\/weizn.net\/?p=90#webpage\"},\"author\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"headline\":\"[\\u8f6c]GTK \\u4e8b\\u4ef6\",\"datePublished\":\"2014-04-03T09:46:40+00:00\",\"dateModified\":\"2014-04-03T09:46:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/weizn.net\/?p=90#webpage\"},\"wordCount\":672,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"articleSection\":[\"GTK\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/weizn.net\/?p=90#respond\"]}]},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\",\"name\":\"zinan\",\"logo\":{\"@id\":\"http:\/\/weizn.net\/#personlogo\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[\u8f6c]GTK \u4e8b\u4ef6 - Wayne&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/weizn.net\/?p=90","og_locale":"zh_CN","og_type":"article","og_title":"[\u8f6c]GTK \u4e8b\u4ef6 - Wayne&#039;s Blog","og_description":"&nbsp; &nbsp; &nbsp; \u4e8b\u4ef6\u662f\u7531X Window\u7cfb\u7edf\u53d1\u51fa\u7684\u7279\u6b8a\u7c7b\u578b\u7684\u4fe1\u53f7\u3002 \u5b83\u4eec\u6700\u521d\u7531X  Window\u7cfb\u7edf\u53d1\u51fa\uff0c\u7136\u540e\u7531\u7a97\u53e3\u7ba1\u7406\u5668\u53d1\u7ed9\u60a8\u7684\u7a0b\u5e8f\uff0cGLib\u63d0\u4f9b\u7684\u4fe1\u53f7\u7cfb\u7edf\u5c31\u4f1a\u4e2d\u65ad\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0cdestroy\u4fe1\u53f7\u7531\u6784\u4ef6\u53d1\u51fa\uff0c\u4f46\u662fdelete- event\u4e8b\u4ef6\u6700\u521d\u7531\u6784\u4ef6\u4e0b\u5c42\u7684GdkWindow\u8bc6\u522b\u51fa\u6765\uff0c\u7136\u540e\u53d1\u51fa\u4e00\u4e2a\u4fe1\u53f7\u7ed9\u6784\u4ef6\u3002   &nbsp; &nbsp; &nbsp; &nbs...","og_url":"http:\/\/weizn.net\/?p=90","og_site_name":"Wayne&#039;s Blog","article_published_time":"2014-04-03T09:46:40+00:00","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"zinan","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"http:\/\/weizn.net\/#website","url":"http:\/\/weizn.net\/","name":"Wayne&#039;s Blog","description":"","publisher":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/weizn.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"http:\/\/weizn.net\/?p=90#webpage","url":"http:\/\/weizn.net\/?p=90","name":"[\u8f6c]GTK \u4e8b\u4ef6 - Wayne&#039;s Blog","isPartOf":{"@id":"http:\/\/weizn.net\/#website"},"datePublished":"2014-04-03T09:46:40+00:00","dateModified":"2014-04-03T09:46:40+00:00","breadcrumb":{"@id":"http:\/\/weizn.net\/?p=90#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/weizn.net\/?p=90"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/weizn.net\/?p=90#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/weizn.net\/"},{"@type":"ListItem","position":2,"name":"[\u8f6c]GTK \u4e8b\u4ef6"}]},{"@type":"Article","@id":"http:\/\/weizn.net\/?p=90#article","isPartOf":{"@id":"http:\/\/weizn.net\/?p=90#webpage"},"author":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"headline":"[\u8f6c]GTK \u4e8b\u4ef6","datePublished":"2014-04-03T09:46:40+00:00","dateModified":"2014-04-03T09:46:40+00:00","mainEntityOfPage":{"@id":"http:\/\/weizn.net\/?p=90#webpage"},"wordCount":672,"commentCount":0,"publisher":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"articleSection":["GTK"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/weizn.net\/?p=90#respond"]}]},{"@type":["Person","Organization"],"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264","name":"zinan","logo":{"@id":"http:\/\/weizn.net\/#personlogo"}}]}},"_links":{"self":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=90"}],"version-history":[{"count":0,"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions"}],"wp:attachment":[{"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}