Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

I want my callback to execute, but not the default callback (or, how to I stop GTK from doing the default action when doing X)?

0
Posted

I want my callback to execute, but not the default callback (or, how to I stop GTK from doing the default action when doing X)?

0

Many times, you are customizing behaviour of a widget, or changing a policy in GTK, and the default action it does it not what you want. To get around this, we rely on a fundamental point in GTK: that GTK, as well as applications, mainly uses signals to get things done in the interface. The process to disable a default action is: • Find out what signal is being emitted and handled by the default handler. Many times you already know the signal since you may be hooking to it already, and observing the default action happen after yours. • call widget.emit_stop_by_name(“signal_name”) (to stop the signal emission in the current widget) • return True (to make sure that the signal won’t propagate into parent handlers that may be the actual culprits for the default action) An example of this usage was reported by Graham Ashton. He had customized a keypress handler for a window, but every time the user triggered the Alt-arrow combination he was handling, the focus moved around between the widge

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.