开发者

Designing loosely coupled components with GTKs event model

开发者 https://www.devze.com 2022-12-21 05:03 出处:网络
This is a fairly vague and open e开发者_StackOverflownded question, but hopefully someone can still provide some insight.

This is a fairly vague and open e开发者_StackOverflownded question, but hopefully someone can still provide some insight.

I am using GTK (through Gtk2Hs with Haskell via GHC) and I am wondering if there is any general advice for handling events. I am used to keeping system components loosely coupled (from OO practice) and this extends to the event model. I want to know if there any patterns of design that can be used to handle/re-fire/propogate events etc. in both Gtk or Haskell that keeps the inter-module/function dependency low.

Thanks.


GTK+ events are identified by strings (in the core GTK+ library, at least). There should be no coupling at all. At least when using the C API, it's perfectly possible to e.g. write programs that try to emit events that are not, in fact, supported by any widgets. Since the event is only identified by a string, the compiler doesn't help guard against this.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号