阅读背景:

子窗口小部件应该处理它自己的事件吗?

来源:互联网 

I often come across a dilemma when implementing GUI. Suppose I have a simple widget hierarchy with a main window which has several child widgets. Should the child widgets handle events (arising, for example, from user input) themselves, or delegate handling to their parent widget? Here's a simple example: a window should close when its' close button is clicked. Who closes the window? Does the window react to the button event and close itself? Or does the button call the Close method on the window? The framework I'm using strongly hints that the preferred way is for child widgets to fire events to their parent widget, which should handle them as it sees fit, so the window would be close like this (in C++-ish pseudocode):I often come across a dilemma when implementing




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: