event-bubbling

Attaching properties to bubbled event object in Javascript

时光总嘲笑我的痴心妄想 提交于 2020-01-01 16:53:29
问题 In Chrome/Firefox I can attach my custom properties to an event object in one handler and read them in a different handler for the same event even if the event handling is bubbled up. I cannot do the same in IE. My custom property is lost while event is bubbled up. Do you know if there's any solution or workaround to this? The following is an example of that problem: <div id="div1"> <input type="button" value="Foo" id="button1"> </div> <script> function attach(el, event, fn) { if (el

Why firing a defined event with dispatchEvent doesn't obey the bubbling behavior of events?

核能气质少年 提交于 2020-01-01 08:06:39
问题 I'm confused with the script below: var event = new Event('shazam'); document.body.addEventListener('shazam',function(){ alert('body'); }); document.addEventListener('shazam',function(){ alert('document'); }); window.addEventListener('shazam',function(){ alert('window'); }); document.body.dispatchEvent(event); When I run this script on my browser, I just get the alert('body'); event. but if i set the capturing parameter of addEventListener (the third optional parameter) to true, all the

find out instantiating object in the constructor of a class

醉酒当歌 提交于 2019-12-29 09:41:59
问题 How can i get hold of the instantiating object from a constructor in java? I want to store reference to the parent object for some GUI classes to simulate event bubbling - calling parents handlers - but i dont wanna change all the existing code. 回答1: Short answer: there isn't a way to do this in Java. (You can find out what class called you, but the long answer below applies there for the most part as well.) Long answer: Code that magically behaves differently depending on where it's being

find out instantiating object in the constructor of a class

南楼画角 提交于 2019-12-29 09:41:33
问题 How can i get hold of the instantiating object from a constructor in java? I want to store reference to the parent object for some GUI classes to simulate event bubbling - calling parents handlers - but i dont wanna change all the existing code. 回答1: Short answer: there isn't a way to do this in Java. (You can find out what class called you, but the long answer below applies there for the most part as well.) Long answer: Code that magically behaves differently depending on where it's being

Is there a way stop bubble in javascript without “e” parameter?

限于喜欢 提交于 2019-12-24 01:47:08
问题 I have see a lot tutorial that tell me the way to prevent bubble is use "e" parameter just like : function(e){ e.preventDefault() } but in some situation,the firebug tell me it is wrong with "e is not define" so is there a way to stop the bubble without the parameter e? 回答1: If you set an event handler by using an element attribute (say, <button onclick="myFunc()"> ) the argument list will be empty. You have to use <button onclick="myFunc(event)"> instead to pass the current event as an

Why is dragging in Raphaël broken by stopping propagation of mousemove in an enclosing element in the bubble phase?

亡梦爱人 提交于 2019-12-23 19:20:15
问题 I am trying to debug an event handling bug in a complicated web application, but I've reduced the problem to a simple example that demonstrates the behaviour that I'm confused by. My example page, based one of the Raphaël examples, is as follows: <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Raphaël · Drag-n-drop Example</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script

Getting the Logical UIElement under the mouse in WPF

一笑奈何 提交于 2019-12-23 13:15:51
问题 It seems that all of the way of retrieving an element under the Mouse relates to Visual Hit testing. Is there some mechanism that I'm missing which would allow me to grab the actual UIElement that represents the current visual tree that the HitTest returns? Summary of what I'm doing: I have a custom tooltip class which relies on doing something based on the UIElement that the mouse is over. Simply put, it hooks into the owning Window's PreviewMouseMove event and updates a "current Item". This

Event Bubbling in WPF Application

时光怂恿深爱的人放手 提交于 2019-12-22 07:58:28
问题 I'm new to WPF. In my WPF app, I have Windows which contain a user defined child control and that user defined child control again contains another user defined child control. Now from the inner most child control, on a button click, I want to fire events on all three controls (i.e. First Grand Child Control, Second Child Control, Third Main Control, and Window). I know this can be achieved through delegates and Event Bubbling. Can you please tell me how? 回答1: Most important piece pf code for

Event bubbling/capturing - where does it start/end?

自作多情 提交于 2019-12-22 05:39:10
问题 I understand that an event has two modes -- bubbling and capturing. When an event is set to bubble, does Javascript checks up to "document" ? When an event is set to capture, does Javascript always starts from "document"? How does Javascript know where to stop/start ? Update: Let's say I have the following code in my body tag. <div id='outer'> <div id='inner'></div> </div> When I set an event to #inner to bubble, does Javascript check up to document or does it stop at #outer? 回答1: Event

How do I stop WPF KeyDown events from bubbling up from certain contained controls (such as TextBox)?

我的梦境 提交于 2019-12-21 09:22:09
问题 My program is quite large, and uses WPF, and I want to have a global shortcut key that uses 'R', with no modifiers. There are many controls such as TextBox, ListBox, ComboBox, etc. that all use letters inside the control itself, which is fine - that's correct for me. But - I want to keep that KeyDown event from bubbling up to the main window , where it would trigger the shortcut any time a user is typing the letter 'R' in a TextBox, for example. Ideally, I would like to be able to do this