event-handling

Difference Between RoutedEventHandler and EventHandler

老子叫甜甜 提交于 2019-12-12 09:35:30
问题 What is the difference between this.Loaded += new RoutedEventHandler(MainWindow_Loaded); and childWindow.MyEvent += new EventHandler(childWindow_MyEvent); 回答1: I assume you want to know what's the difference between Events and Routed Events. These 2 articles might help you: https://msdn.microsoft.com/en-us/library/ms742806(v=vs.100).aspx (a MSDN article) http://joshsmithonwpf.wordpress.com/2008/03/18/understanding-routed-commands/ (a great article about Routed Commands that also contains a

Javascript Scroll Handler not firing

痞子三分冷 提交于 2019-12-12 09:31:25
问题 All I'm trying to do is to call a function when a DIV is scrolled.For simplicity sake Im not specifying anything else. Also I am only looking at DOM compliant browsers like Chrome, Safari (not IE). MY problem is that the scroll handler never gets called. If I replace the scroll to click , it works when I click. Somehow the scroll is not working. Please note: I cannot use jQuery :( Here is my code: HTML: <div id="test">--long content--</div> JS: function myFunc() { console.log('in myFunc'); }

Add an event handler to each control on a form at runtime VB6

喜夏-厌秋 提交于 2019-12-12 08:54:18
问题 I have a VB6 application where I'd like to have a consistent behavior among its controls application-wide. One of the behaviors, for example, would be highlighting a text box when it gains focus and removing the highlight when it loses focus. I'd like this to happen on every form. What I'm trying to do is have one sub procedure that can be called by all forms when they load that will make this behavior happen. That way, I don't have to manually code for each individual text box to make it

Understanding the window.event property and its usage

扶醉桌前 提交于 2019-12-12 08:33:29
问题 I don't understand the motivation behind window.event or window.event.srcElement. In what context should one use this? What exactly does it represent in the DOM? 回答1: Here what w3school says about event object: Events are actions that can be detected by JavaScript, and the event object gives information about the event that has occurred. Sometimes we want to execute a JavaScript when an event occurs, such as when a user clicks a button. You can handle events using: node.onclick = function(e)

Do you need to “unwire” an anonymous function/lambda

…衆ロ難τιáo~ 提交于 2019-12-12 08:30:11
问题 My understanding is that any event handlers wired up in C# need to be unwired as such. Object myObject = new Object(); myObject.Event += EventHandler; //Wired myObject.Event -= EventHandler; //Unwired But do you need to unwire the following code? and if so, how? Object myObject = new Object(); myObject.Event += (object sender, EventArgs e) => { }; //Wired myObject.Event -= ????? //Unwire? How? My assumption is no? 回答1: Yes, you need to (*) and you need to do it like this: Object myObject =

How to list all registered events of a DOM node using Javascript?

房东的猫 提交于 2019-12-12 08:26:50
问题 I can add or remove an event handler for a DOM node. Is it possible to find out all the registered events handlers of a given DOM node? I am referring to straight Javascript meaning no frameworks or toolkits like jQuery, dojo, Prototype, GWT, etc. If the answer is no, any reason why? Security issues? 回答1: I know this is an old question, but just in case, for chrome you can use getEventListeners https://developers.google.com/chrome-developer-tools/docs/commandline-api#geteventlistenersobject

EventHandler inside a TFrame?

陌路散爱 提交于 2019-12-12 08:14:53
问题 I have a TForm (TVehicleEditForm) with 3 identical TFrames (TVehicleUnitFrame) inside. The idea was that every instance of the frame handle own events by a eventhandler inside the frame. The problem is that the eventhandler is not called. I have tried to assign the eventhandler by code inside the frame by overriding the Create method but the handler is not called in that case either. But if I assign the eventhandler outside the frame from the form it works fine. Like this:

What's the difference between passing this vs. ClassName.this from an event handler when passed to Intent constructor?

别来无恙 提交于 2019-12-12 07:53:05
问题 In the earlier Android Programming Tutorial, page 192, we see an implementation of LunchList#onOptionsItemSelected . Within this implementation we see two Intent s passed to startActivity : one whose constructor is passed LunchList.this , the other whose constructor is passed this . What's the difference? See lines 78 - 91 here. Note how onOptionsItemSelected is not declared within an inner class. In Android/Java does the value of this change within the context of event handlers or function

One Liner: WeakReference-to-a-Lambda Event Handler

核能气质少年 提交于 2019-12-12 07:49:17
问题 Can you see downsides to this one-liner other than the fact that multiple uses of it would violate the DRY principle? It seems straightforward but the fact that I haven't seen others propose it makes me wonder if there's a downside to it. This bit of code creates a WeakReference to a method and then registers an event handler that invokes the reference's target. SomeEvent += (sender, e) => ((Action)(new WeakReference((Action)ProcessEvent)).Target)(); Thanks, Ben 回答1: I don't think that

How can I track subscribers to an event in C#?

你说的曾经没有我的故事 提交于 2019-12-12 07:47:10
问题 Is there some hidden class property which would allow to know this ? 回答1: If you have access to the actual delegate (if you're using the shorthand event syntax, then this is only within the actual declaring class, as the delegate is private ), then you can call GetInvocationList(). For instance: public event EventHandler MyEvent; To get the list of subscribers, you can call: Delegate[] subscribers = MyEvent.GetInvocationList(); You can then inspect the Method and Target properties of each