event-handling

Angular 2 how to keep event from triggering digest loop/detection cycle?

社会主义新天地 提交于 2019-11-27 08:05:37
We are implementing drag and drop functionality with Angular 2. I'm using the dragover event just to run the preventDefault() function. So that the drop event works as explained in this question . The dragover method is being handled by the onDragOver function in the component. <div draggable="true" (dragover)="onDragOver($event)"> ... In the component, this function prevents default behavior allowing for the dragged item to be dropped at this target. onDragOver(event) { event.preventDefault(); } This works as expected. The dragover event gets fired every few hundred milliseconds. But, every

What is the proper way of doing event handling in C++?

£可爱£侵袭症+ 提交于 2019-11-27 08:03:17
I have an application that needs to respond to certain events in the following manner: void someMethodWithinSomeClass() { while (true) { wait for event; if (event == SomeEvent) { doSomething(); continue; } if (event == SomeOtherEvent) { doSomethingElse(); continue; } } } This would be running is some thread. In some other threads, operations would create and fire the Events. How do I get these Events to reach the above method/class? What is the proper strategy or architecture for implementing event handling in C++? The C++ Standard doesn't address events at all. Usually, however, if you need

Event handler and memory leaks

寵の児 提交于 2019-11-27 07:49:10
问题 I analyze a VB.NET project and there are some objects (child MDI form) that are disposed, but not removed by the GC. The MemoryProfiler analysis find, among others, the following: "This instance is disposed and still indirectly rooted by an EventHandler. This often indicates that the EventHandler has not been properly removed and is a common cause of memory leaks. The instances below are directly rooted by EventHandler(s). Investigate them to get more information about this issue..." Now, I

Proper use of .on method in Jquery

不打扰是莪最后的温柔 提交于 2019-11-27 07:46:25
问题 I really liked the .live method as it was straightforward and essentially not much different than your standard event handler. Alas, it was deprecated and I'm left with the .on method. Basically, I'm loading and dynamically loading content that I'll need the same event handler triggered on. Rather than add the event handler twice or however many times. .live was great for this, but .on has replaced it and I just can't seem to get it to work. check this code: jQuery('#who_me').live('click',

HTML5 event listener for number input scroll - Chrome only

眉间皱痕 提交于 2019-11-27 07:44:08
问题 I'm playing around with some HTML5 elements, and ran into a fun behavior. This only works in Chrome. Using an input type of number, you can set the min, max, and step, and get up and down arrows to control the input. <input type="number" min="0" max="100" step="5" /> I've found that binding a click event listener captures presses on the arrows, as a change won't actually occur until the field is blurred. You can also use the up and down arrow keys on your keyboard to change the value within

Child elements of scrollviewer preventing scrolling with mouse wheel?

只愿长相守 提交于 2019-11-27 07:35:31
I'm having a problem getting mouse wheel scrolling to work in the following XAML, which I have simplified for clarity: <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" CanContentScroll="False" > <Grid MouseDown="Editor_MouseDown" MouseUp="Editor_MouseUp" MouseMove="Editor_MouseMove" Focusable="False" > <Grid.Resources> <DataTemplate DataType="{x:Type local:DataFieldModel}" > <Grid Margin="0,2,2,2" > <TextBox Cursor="IBeam" MouseDown="TextBox_MouseDown" MouseUp="TextBox_MouseUp" MouseMove="TextBox_MouseMove" /> </Grid> </DataTemplate> </Grid.Resources>

Why does Boost.Asio not support an event-based interface?

此生再无相见时 提交于 2019-11-27 07:31:12
I am attempting to understand Boost.Asio, with the intention of potentially implementing a signaling system using condition variables in conjunction with Boost.Asio. I have seen the other StackOverflow questions boost asio asynchronously waiting on a condition variable , boost::asio async condition , and boost condition variable issue , but none of these questions/answers have satisfactorily touched on an essential question that I have: Is it true that, and/or is there a fundamental reason why, Boost.Asio is not applicable to, or a natural fit with, condition variables? My thinking is that

Handling end process of a windows app

坚强是说给别人听的谎言 提交于 2019-11-27 07:30:52
Is it possible to capture the task manager end process of a windows application within the same windows application itself? I am using a C# 2.0 win app and I would like to do some database processing (change a flag from 'Y' to 'N' in the DB) when an end process happens. Foredecker No, it is not possible to hook the operating system's decision to end a process. Note, this is not done by task manger, ending a process is the responsibility of the kernel. You will need to do two things here: Connect event handlers to the normal user interface messages that tell a application to exit. Use these

How to subscribe to other class' events in c#?

坚强是说给别人听的谎言 提交于 2019-11-27 07:28:06
A simple scenario: a custom class that raises an event. I wish to consume this event inside a form and react to it. How do I do that? Code examples, please! Note that the form and custom class are separate classes. public class EventThrower { public delegate void EventHandler(object sender, EventArgs args) ; public event EventHandler ThrowEvent = delegate{}; public void SomethingHappened() { ThrowEvent(this, new EventArgs()); } } public class EventSubscriber { private EventThrower _Thrower; public EventSubscriber() { _Thrower = new EventThrower(); //using lambda expression..could use method

How can I change the EditText text without triggering the Text Watcher?

守給你的承諾、 提交于 2019-11-27 07:21:24
I have an EditText field with a Customer Text Watcher on it. In a piece of code I need to change the value in the EditText which I do using .setText("whatever") . The problem is as soon as I make that change the afterTextChanged method gets called which created an infinite loop. How can I change the text without it triggering afterTextChanged? I need the text in the afterTextChanged method so don't suggest removing the TextWatcher . You could unregister the watcher, and then re-register it. Alternatively, you could set a flag so that your watcher knows when you have just changed the text