[gtk4] How to keep evnet bubbling?

a controller may indicate that a received event was consumed and propagation should therefore be stopped

How to make the GtkGestureClick at the bottom also receive events when two GtkGestureClicks are overlapped?

Bubbling happens from target widget trough tree to the top, so just add GtkGestureClick to the bottom widget, and add it to parent as well if required. You can stop event from bubbling up with

controller.set_state(Gtk.EventSequenceState.CLAIMED)

So if you have done with event, and don’t want parent to get it, do this.

So if you have done with event, and don’t want parent to get it, do this.

I want parents to get it

Clearly state my needs:

widget tree:
  A
    B      //   controller(gesture_click)
       C   //   controller(gesture_click)

I hit C with the left mouse button, but I also want B to receive the event as well, as if C doesn’t exist.

Reference: Event: stopPropagation() method - Web APIs | MDN

But at present, GTK4 prevents further propagation by default.

How do you do the opposite effect of event.stopPropagation() in gtk4?

But at present, GTK4 prevents further propagation by default.

For me by default parent of widget gets click for me, so I actually had to tell child to claim event explicitly so it doesn’t get it.

Could you throw in some code examples?

Thanks. I found this problem on GtkButton. I went to see the source code and found Gtk. EventSequenceState. CLAIMED

Describes the state of a GdkEventSequence in a GtkGesture.

I want to ask again, will keyboard events also bubble up? Can it also be stop?

Honestly this I don’t know, as GtkEventController is different class from GtkGesture, and I did not find equivalent of this.

edit: I suggest you to read this Gtk – 4.0: Overview of GTK input and event handling

This paragraph indicates that key strokes are seen differently - key strokes are detected at main window first, and if unclaimed then go after widget having focus set.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.