什么是等同于.NET的JavaScript冒泡事件?事件、NET、JavaScript

2023-09-06 23:12:24 作者:养条狗取名前男友

我觉得JavaScript有一种机制,允许气泡从自上而下,下了事件。什么是等值的.NET WINFORM(不是ASP.NET)?

I think Javascript has a mechanism that allows to bubbling events from top down and down up. What's the equivalent in .NET WINFORM (not ASP.NET) ?

事件/代表在.NET中避免这个问题来处理该消息更新发送给用户,所以我不明白为什么bubling不可能存在的任何根本的原因自动化观测/设计模式。

Events/Delegates in .NET automates the Observer/Design Pattern by avoiding the subject to handle the message update sending to subscribers so I can't see any fundamental reason why bubling couldn't have existed.

活动/代表允许松散耦合相比,使用IObserver,以同样的方式,如果鼓泡实现它还将允许松耦合而不是做继承和硬线呼叫到基父

Events/Delegates allows loose coupling compared to using IObserver, in the same way if bubbling was implemented it would also allow loose coupling instead of doing inheritance and hard-wire the call to the base parent.

推荐答案

这具有的非常的一点做用JavaScript,鼓泡是DOM的属性。从而重新presents文档在类似树的层次结构,使其自然传递未处理了树事件

This has very little to do with JavaScript, bubbling is a property of the DOM. Which represents documents in a tree-like hierarchy, making it natural to pass events that are not handled up the tree.

这不近,以及在一个窗口层次相对应。主要的问题是,如果你嵌套窗口深深地那么你已经自己一个程序,它永远绘制UI的狗。然而,默认的窗口过程的确实的气泡窗口的消息到父。这是有选择性的行为,这取决于特定消息。例如:一个WM_MOUSEWHEEL消息气泡,寻找知道如何滚动视图的父窗口。但WM_LBUTTONDOWN没有泡沫,父窗口通常不会有多大用处鼠标点击一个区域,它不拥有。除也许将焦点设置到控制,一些已经自动发生。

This doesn't nearly correspond as well in a window hierarchy. Chief problem being that if you nest windows deeply then you'd have been yourself a dog of a program that takes forever to draw the UI. Nevertheless, the default window procedure does bubble window messages to the parent. This is selective behavior, it depends on the particular message. A WM_MOUSEWHEEL message for example bubbles, looking for a parent window that knows how to scroll the view. But WM_LBUTTONDOWN does not bubble, the parent window wouldn't normally have much use for a mouse click on an area that it doesn't 'own'. Other than perhaps to set the focus to the control, something that already happens automatically.

您绝对可以让IT泡沫自己,只是将消息发送给家长。实际上,这已经发生了。控制通常产生的MouseDown或Click事件。这是由在表单的事件处理程序认购。不同的模式,同样的效果。

You can certainly make it bubble yourself, just send the message to the parent. In effect this already happens. A control normally generates a MouseDown or Click event. Which is subscribed by an event handler in the form. Different model, same effect.