event-handling

Event subscription on async method

南楼画角 提交于 2019-12-12 15:04:17
问题 I wanna launch the LoadDataAsync in 2 ways. First by an event with the subcription in FormLoad() and by a classic method ManualLoad() . But I can't make it work. I can't make subscription on task return. With void it's works, but with void can't await in the ManualLoad() method. How make both ways work? public delegate void ProductDelegate(long? iShopProductId); public event ProductDelegate ProductSelectionChanged = delegate { }; public async Task LoadDataAsync(long? iProductId) { //await

C++ to C# event handling

冷暖自知 提交于 2019-12-12 14:29:01
问题 So I've got my C# WinForm Application, from it I call my C++ CLI MFC dll library. But there are some events on my C++ library, even this events happens in native (non-CLI) part of this library. And I need to call some code from my C# application and get some data maybe right there on this event. so when this native function is called from client side : bool __stdcall ClassName::WorkQuery() { ...... switch(pp->code) { case READCOMPLEX: .......... I need to bring the Data from C# so I need to

Workaround for generic event handler in Windows Forms

泪湿孤枕 提交于 2019-12-12 13:13:53
问题 Quite some time ago, I noticed that the Windows Forms editor of Visual Studio does not support events which contain generic type parameters. For example, an event like public event EventHandler<ListEventArgs<int>> MyStrangeEvent { add { ... } remove { ... } } where public class ListEventArgs<T> : EventArgs { List<T> args; } does not even show up in the event list in the property manager of Visual Studio. Now, this is a somewhat artificial example that could easily be modified to work in

Is it possible to target an EventHandler in a lambda expression?

泪湿孤枕 提交于 2019-12-12 13:08:22
问题 For a simple example, if I had some sort of button UI class, could I write a function that takes an expression that points to its Click event handler: SomeMethod<SomeButtonClass>(button => button.Click); I'm trying to eliminate some magic strings currently being used for a system to make events awaitable. The code in question is derived from a blog post by Frank Krueger (a worthwhile read, if you want some background). public static Task<TEventArgs> GetEventAsync<TEventArgs>(this object

event when div ngIf is rendered

感情迁移 提交于 2019-12-12 12:43:00
问题 I was looking at issue at: https://stackoverflow.com/a/44737636/973651 I've a div with an ngIf condition, and I'd like to capture an event for when the div gets rendered. Supposedly, you can use the AfterContentInit event. The article I cited above, shows an example, which I've replicated but no luck in getting it to work. I don't know what I'm doing wrong, but I can't get this to work. I get no errors, but it doesn't work for me. My directive is defined as: import { AfterContentInit,

Changing the Panels of a JFrame “disable” the inputMap of the new Panel inserted

给你一囗甜甜゛ 提交于 2019-12-12 12:15:45
问题 Description of the problem: I have a JFrame, inside this JFrame there is a JPanel with a button, when I press the button an action listener change the current JPanel with a new JPanel, which contains other two JPanels, those two have an inputMap that when the user press the key "up" make something on both of them. The problem is: when I change the JPanel with the new one the "up" key won't do anything. Here is the code: is a SSCCE, so you just have to copy and paste to see what it does. This

Matplotlib pick event order for overlapping artists

被刻印的时光 ゝ 提交于 2019-12-12 12:12:15
问题 I'm hitting a very strange issue with matplotlib pick events. I have two artists that are both pickable and are non-overlapping to begin with ("holes" and "pegs"). When I pick one of them, during the event handling I move the other one to where I just clicked (moving a "peg" into the "hole"). Then, without doing anything else, a pick event from the moved artist (the peg) is generated even though it wasn't there when the first event was generated . My only explanation for it is that somehow

Are directly assigned event handlers actual object properties?

て烟熏妆下的殇ゞ 提交于 2019-12-12 12:04:00
问题 I got stuck trying to answer this question: Explaining odd behavior in javascript. While researching, I found that event handlers assigned directly to host objects present a strange behavior: they can be accessed as properties of the object, but somehow they don't appear to be actual properties. For example, if I define a variable on the global scope, it looks like any other property of window : ​var foo = "foo"; console.log(Object.getOwnPropertyDescriptor(window, 'foo')); // Object {value:

Vanilla Web Component custom event attributes and properties

帅比萌擦擦* 提交于 2019-12-12 12:01:35
问题 Using Web Components without any framework, what is the proper way to implement a custom event? For example, say I have a custom element x-pop-out that has a custom event of pop I would want all of the following to work: <x-pop-out onpop="someGlobal.doSomething()"/> var el = document.getElementsByTagName('x-pop-out')[0]; el.onpop = ()=> someGlobal.doSomething(); //or el.addEventListener('pop', ()=> someGlobal.doSomething()); The last one I get how to do, but do I need to custom implement the

Javascript: attaching OOP methods to events and the 'this' keyword

荒凉一梦 提交于 2019-12-12 11:44:17
问题 I am new to OOP Javascript and am having trouble with the this keyword and events. What I'm trying to achieve is: I have multiple DOM objects and want to not only bind a common event to them, but keep some data about the aforementioned objects in a global container (to increase runtime performance). So what I do is basically this: function ClassThatDoesSomething() { /* keeps node ids for processing in this.init */ this.nodes = new Array(); /* keeps processed node data for fast access */ this