无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

(五)GTK4 鍵盤鼠標(biāo)事件

2023-04-09 12:27 作者:FineClassFuture  | 我要投稿

????GTK的教程就是gtk-demo,說明文檔就是API文檔https://docs.gtk.org/gtk4

????gtk4-demo中原本應(yīng)該看例子drawing area,但是這繪制效果......看了下,只是drawing area的事件,沒有參考意義。

????gtk4-demo中print例子還是drawing?area只能選顏色,但沒有任何繪制效果,失敗的例子?

????gtk4-demo中有g(shù)estures,看了下翻譯是手勢,還是drawing?area。

????

????進(jìn)入文檔主頁?https://docs.gtk.org/gtk4/,看到有個(gè)“Overview of GTK input and event handling”

????Inside?GTK, every such input device is represented by a?GdkDevice?object.

????使用GdkDevice來表示輸入設(shè)備

????有這么一張圖

Event controllers and gestures

Event controllers are standalone objects that can perform specific actions upon received?GdkEvents. These are tied to a widget, and can be told of the event propagation phase at which they will manage the?events.

Gestures are a set of specific controllers that are prepared to handle pointer and/or touch events, each gesture implementation attempts to recognize specific actions out the received events, notifying of the state/progress accordingly to let the widget react to those. On multi-touch gestures, every interacting touch sequence will be tracked?independently.

Since gestures are “simple” units, it is not uncommon to tie several together to perform higher level actions, grouped gestures handle the same event sequences simultaneously, and those sequences share a same state across all grouped gestures. Some examples of grouping may?be:

  • A “drag” and a “swipe” gestures may want grouping. The former will report events as the dragging happens, the latter will tell the swipe X/Y velocities only after recognition has?finished.

  • Grouping a “drag” gesture with a “pan” gesture will only effectively allow dragging in the panning orientation, as both gestures share?state.

  • If “press” and “l(fā)ong press” are wanted simultaneously, those would need?grouping.

Shortcuts are handled by?GtkShortcutController, which is a complex event handler that can either activate shortcuts itself, or propagate them to another controller, depending on its?scope.


????在github上找到個(gè)例子,是個(gè)小游戲

????https://github.com/lavalfils/poc_gtk4_2D_action_game

瞬間回到小時(shí)候了

????看看如何捕捉鍵盤事件

// --- add keyboard callback ---

GtkEventController *keyboard = gtk_event_controller_key_new();

gtk_widget_add_controller(window, keyboard);

g_signal_connect(keyboard, "key-pressed", G_CALLBACK(key_pressed), window);

g_signal_connect(keyboard, "key-released", G_CALLBACK(key_released), window);


這樣就可以在文檔里搜索了

GTK另一個(gè)麻煩(煩人)的地方,小版本更改中也會(huì)把一些API/參數(shù)更改掉



現(xiàn)在還有 鼠標(biāo)按鍵事件 怎么獲???

(五)GTK4 鍵盤鼠標(biāo)事件的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
双辽市| 陇南市| 弥渡县| 茂名市| 临澧县| 西林县| 阿克苏市| 吴忠市| 四会市| 德昌县| 正宁县| 屏东市| 东台市| 丰宁| 保德县| 吴堡县| 托克托县| 阿瓦提县| 扶余县| 博白县| 封丘县| 南丹县| 甘肃省| 广东省| 盐亭县| 商都县| 华池县| 城口县| 修武县| 巴中市| 锡林浩特市| 格尔木市| 望城县| 唐山市| 彰武县| 内江市| 巨鹿县| 阜南县| 蓝田县| 南皮县| 瓦房店市|