Questions tagged [event-handling]

Event handling is a coding pattern related to acting on messages between a source and one or more subscribers. A point listener in the source provides a way in which subscribed code can consume messages raised from the source.

Filter by
Sorted by
Tagged with
17
votes
5answers
6k views

Using sounds in Java

I'm trying to apply sound today, and the goal in mind was a simple violin tuner. The actionListener seems repetitive/ How might I optimize it (what I tried just ...
17
votes
2answers
28k views

Generic EventArgs to go with generic EventHandler?

There is as of .NET 2.0 a generic EventHandler delegate type, which can be used to define an event in terms of the EventArgs ...
15
votes
2answers
2k views

Using events together with interfaces in VBA

Introduction Because of the limitation of VBA in using events in interfaces I was searching for a kind of workaround. For sure I also read this which also provides an approach, but I was searching ...
14
votes
1answer
30k views

Use of Async/Await for EventHandlers

I have a MVC WinForms application. I am using Dependency Injection with Ninject as the IoC container. ...
13
votes
3answers
4k views

Simple event management system

In an effort to rid my code of jQuery, I wrote a custom global event management/handling system. I was expecting this to be hard as, from what I've read, most people don't create their own. It's far ...
13
votes
1answer
5k views

My Event-handling system

I have written about 180 lines of code that implements an Event system. I would like a general review about the code and I'd love comments about the usability of it. (Is the code useful? Would you ...
13
votes
1answer
24k views

Click event function that checks to see if form field is valid

What I'm building is a URL builder. A marketing person inputs a URL and can test that URL to see if it's valid, then they select a demand channel and then hit 'Generate Campaign URL'. I've omitted the ...
12
votes
2answers
239 views

Emulation of SE's text input control for tags

Introduction I used React to write a component, which is meant to be a faithful emulation of the input for "Tags" which you see at the top of every question/topic on SE. Why this project? If you're ...
11
votes
7answers
2k views

Too-high / too-low guessing game in Swing

I have created this program and it works fine. It's just that its too wonky and huge so I was wondering if anyone knew how I could shorten the program so I didn't have to put all of these into each ...
11
votes
2answers
7k views

Event Listener and Publisher

This is my first attempt at creating an event system. My plan is that upon publishing, the listener receives both a reference to the model and to the publisher. This allows the publisher class to ...
11
votes
1answer
2k views

C++14 Event System

I've created a simplified event system for C++14. The code is commented, so it shouldn't be hard to read. There's also a simple usage scenario below. It is still a work in progress and uses some not-...
10
votes
5answers
13k views

One-shot events in C#

I have a class that performs some long-running operation. This class exposes a Completed event. I'd like clients that use this class to register to get notified ONLY ONCE when the class completes ...
10
votes
1answer
606 views

Finger painting code

I have a very simple view that handles touch events and draws accordingly. It's nothing significant, but it does use a bit more CPU than I would like (35%). Again, it is the bare minimum (<90 lines)...
10
votes
2answers
435 views

In memory data access for CSV files that may have changed

I'm reading data from CSV files and store the result in a simple DataContext instance that gets injected throughout my application. ...
10
votes
0answers
223 views

Windows keylogger in C++

Windows keylogger in C++ Known issues: Not implementing rule of five Having to use hack to use member variables, out_, in static method Pressing caps-lock won't ...
9
votes
2answers
158 views

TestExplorerWindow, the event-tossing UI

Following up on Integrating Unit Testing functionality into an old COM-based IDE, I made quite a few changes to the UI, and now the code-behind for my ...
9
votes
2answers
443 views

Dynamic network messaging

I'm building a client and server for a game but wanted a generic messaging system in a shared library that let me focus on application logic and was largely separate form the underlying networking I/O ...
9
votes
1answer
3k views

Implementing my own signal slot mechanism using C++11

I programmed in C# and I used the Qt framework. Both of them have their own signal slot mechanism which are really powerful. I looked at several implementations in C++ and based on what I learnt from ...
8
votes
3answers
801 views

Fourteen buttons with hover effects

I have just started learning coding and am trying to clean up a website that I am making. Everything is functional, but I imagine there is a better way write everything that is there, because a good ...
8
votes
4answers
517 views

Making an Action<T> event also usable as Action<object> and Action in C#

Edit I've added a second pass at this problem based on the answers that have been posted by other users so far: https://codereview.stackexchange.com/a/221525/75659 Context Before presenting the ...
8
votes
2answers
4k views

WinForm Calculator

I'm looking to get this cleaned up. ...
8
votes
1answer
2k views

How can I condense several IBAction methods in a class with a delegate?

I have the following class: MyProtocolClass.h ...
8
votes
2answers
6k views

Yet another event dispatcher in c++11

I've written an event dispatcher for a private project which task is to collect events from different threads and dispatch them in a single thread: ...
8
votes
3answers
1k views

Mask latitude text field

I have an input element on one of the pages. This input is supposed to take a string of digits from a user. In order to enhance UX I'd like to mask input's value at any given time. Like so: What came ...
8
votes
1answer
5k views

Angular directive to disable a button when clicked, allowing re-enabling as needed

I have written an Angular Directive that disables a button after it has been clicked, to prevent double posting / saving of data. This works fine in most of our use cases. However, in some situation ...
8
votes
2answers
2k views

Overriding all Access form control AfterUpdate methods

I have a set of custom event handlers for all my textboxes and combo boxes. The reason for this is my users want the bound form (to SQL Server) to immediately push changes to the recordset, rather ...
8
votes
1answer
229 views

“Block a website” script with vanilla JavaScript

I use this script to block access to a one or more websites with vanilla JavaScript. I find that it helps me avoid some addictive news websites that make me depressed. (Credit to Marat Tanalin for ...
8
votes
2answers
1k views

Javascript typehead using debounce

This is the code I wrote for making a JavaScript typeahead/autocomplete, which displays cities based on the user input. It would be great if you could suggest some improvements on the code quality. ...
8
votes
2answers
2k views

Recorder for keyboard and mouse events

I'm building an event recorder. So far the code looks clean, but I feel like I'm missing something that can make this code even better. Is composition a better solution? If yes, how can I do it ...
8
votes
0answers
419 views

Simple, intuitive and (hopefully) safe EventDispatcher

For my own game engine I need an event system. I tried to avoid the single-huge-enum-approach for minimizing compile times. The BasicEventListener is the (...
7
votes
2answers
3k views

Updating dimensions when focus is lost from any of 9 columns

How can I write this more pretty? ...
7
votes
3answers
212 views

Downloading files from a Mozilla file server via FTP

All classes on GitHub repo This is the code for downloading files from a FTP-server running Mozilla Fileserver. FtpItem is the interface for the two classes ...
7
votes
2answers
1k views

JPaint (Java painting app)

I have this painting app called JPaint in Java and I'm wondering if it could be improved. The variable declaration seems repetitive and long, and I think it might ...
7
votes
3answers
200 views

Notifying the UI that Issues Were Found

Our Rubberduck VBA IDE Add In does some static code analysis, and then reports all of the found issues back in a gridview. This analysis can take a long time for larger projects and the UI appeared to ...
7
votes
2answers
153 views

eCommerce Mockup App in JS

I have completed this mockup eCommerce app using Javascript. This version can add products into a shopping cart and automatically calculate the order summary in the shopping cart. It can also delete ...
7
votes
3answers
527 views

Carousel in Vanilla JavaScript

I finally got my carousel to work in JavaScript, and I want to know what you guys think about it and what I can do better. ...
7
votes
1answer
644 views

Paint rectangles to canvas using mouse

Just wanted to post this here to see if anyone has any critiques of my code, if I'm drawing the background image most efficiently, or if I'm doing anything which could benefit from obvious ...
7
votes
1answer
3k views

“Function Buffer” to avoid triggering an event handler too frequently

If some big event handler is triggered too frequently, it will cause computer lagging. In my example $(window).resize(), I want the function to be called after the ...
7
votes
1answer
2k views

Even handler for text input preview

In a WPF application I have the following event handler for PreviewTextInput event in ComboBox control. The main purpose of this ...
7
votes
2answers
852 views

Drag and drop single files on different targets for different purposes

I have three text fields (DevExpress ButtonEdits set to read only) on a Windows Forms app. They look like this: They're used by dragging and dropping a single ...
7
votes
1answer
126 views

Detecting two keys pressed in quick succession

My computer has been having this issue where when I press a key, two key presses get registered. The goal of this program is to detect the time delta between the two keys so that I can set an ...
7
votes
1answer
175 views

My EventBus system

I decided to roll out my own EventBus system which is intended to be thread-safe. Hence a review should focus extra on thread safety apart from all regular concerns. The ...
7
votes
1answer
6k views

Event Handling system in Java

I have written a system for handling the dispatch of events between objects. (I need this functionality for a larger project I am working on. Objects should be able to dispatch events without knowing ...
7
votes
2answers
61 views

Vanilla Javascript: Chained AJAX request

I'd be grateful for a review of my AJAX request. If I have taken the correct approach here and especially any security concerns! I am creating a Purchase Order system for my manager (as part of an ...
7
votes
1answer
2k views

Event dispatcher / listener

I'm working on a program that will be significantly multi-threaded. I need to respond to events between objects and threads so I've come up with the following code. ...
7
votes
1answer
1k views

Animations when navigation items are clicked

I'm a beginner in jQuery and am wondering how I could write the following code shorter, since I'm repeating a lot. Working example ...
7
votes
1answer
492 views

Custom event hub

I'm creating an event hub object in for a large project I am building in JavaScript. The project will have modules in charge of the UI, commands, and rendering. Each module will use this hub for ...
7
votes
1answer
171 views

Threadsafe oneshot-event which fires on subscription if the event was fired in the past

Assumptions Basically, a Connection class has a "Disconnect" event. Subscribing to this event isn't thread-safe, because the disconnection may fire from another thread right before I subscribe. So ...
7
votes
1answer
114 views

Simple integration of async and tkinter in Python

I've been a fan of coroutines and asynchronous programming for a while, and I recently took a trip down memory lane to when I was using Python's tkinter module for ...
7
votes
1answer
121 views

First Javascript program - Snakes game on HTML canvas

I'm relatively new to programming but my most familiar languages are Java, C# and Haskell and this is my first javascript program. All the concepts used in here were just the first thing that came to ...