The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
5
votes
2answers
577 views

Toggling dropdowns using jQuery, with binding and unbinding

This code is used to toggle some dropdowns. I've added the click event on the document to close the dropdown on click outside, but I'm not sure if I'm doing it the right way. I want it to be optimized ...
3
votes
0answers
40 views

Periodically monitor if record is not updated using Node, Event and setTimeOut

Here is my scenario: Every user checks in every five minutes. If some user doesn't check in after 5 minutes, I should be able to keep track of it. If some user doesn't check in N number of times, an ...
4
votes
1answer
54 views

Three identical AJAX button handlers in three views

In my Rails 4 app I have this event listener: ...
4
votes
2answers
310 views

Handling events in a multi threaded environment

I have a service that raises multiple events, some of them can be raised at the same time. I need to process those events and run a potentially long running method based on the event arguments. What I ...
0
votes
1answer
353 views

Form validation using IIFE and closure [closed]

Problem statement Write an IIFE in which we have to validate the input provided from a form using closures. The form consists of name, email, phone, address in which name, email and phone number ...
4
votes
3answers
166 views

Track mouse coordinates

Problem Statement Write a JavaScript program that prints the mouse coordinates in a text area when the mouse cursor is moved over the HTML document. Expected Output Solution ...
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 ...
4
votes
2answers
923 views

C++ EventHandler class, invoking & arguments

This is my EventHandler class, which is extremely simple and can be used on lambdas and similar: ...
5
votes
3answers
4k views

Detect how long an HTML button is pressed

I recently had the need to detect how long a button is pressed and perform different actions based on that. I found some examples on Stack Overflow, but the ones I looked at showed how to use ...
2
votes
1answer
44 views

Handler for bidirectional unit conversion form

Building a form where values can be entered in either pounds or kilos. Script is... ...
3
votes
1answer
152 views

Animating sprite without libraries

I'm building a small game in pure JS for my own learning purposes, using sprites to model players. Before I go further, I want to try to get the animation down. The below code should produce a blank ...
2
votes
2answers
642 views

Xml messages processing networkstream [closed]

I'm currently processing xml messages with C#. It is working But I'm not confident that my code is fast enough. There are 3 possible messages I can receive. When I receive one the message an event is ...
2
votes
2answers
4k views

Using actionPerformed() to call different methods per radio button selection

My Java is very rusty and I have been unlucky finding a better way to accomplish this task. I have two different methods which get called based on which radio button is selected. Is there a cleaner ...
4
votes
2answers
119 views

Pub/Sub in JavaScript

This seems to work, but for some reason I'm not entirely sure about it. Can anyone point out any issues with this simple pub/sub library? Thank you! ...
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 ...
4
votes
2answers
2k views

Designing a Backspace key

I have designed a Backspace button (part of a keyboard which I am designing) in windows forms and it works perfect with no errors (the code works very good). This button deletes what is inside the ...
3
votes
1answer
1k views

Resize Images Dynamically

I set out to make a simple dynamic resize method for images. Obviously, it's better to serve images that are pre-sized to avoid unnecessary server loads. But it was fun to make for a novice/beginner ...
3
votes
2answers
541 views

Custom event handler in Javascript

In my web projects I often need a simple way to trigger callbacks defined somewhere else. Leaving jQuery finally behind me, I was missing their simple event system and tried to create my own. I'd like ...
2
votes
0answers
2k views

C++ 14 event bus implementation

The code allows you to subscribe to events and publish events via an EventBus class. Events are identified by a source and subject. Events can have a single ...
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. ...
6
votes
2answers
819 views

Python Event Dispatcher

This code creates a singleton event dispatcher. It's called like this: ...
3
votes
1answer
177 views

Pomodoro Timer via setTimeout()

I've made my attempt to code timer entirely by hand using jQuery. No external libraries to manage time at all. ...
1
vote
1answer
56 views

Javascript event handling via switch

The application I am developing with has many input fields that interact with one another via the onchange event. When developing started, the goal was to create a framework that makes it easy to ...
4
votes
1answer
887 views

C++ EventHandler Class

I need to have some thread-safe event handler (like C#'s EventHandler), so I made one. Here is my event handler class and sample code (compiled with VS2013). Is ...
6
votes
1answer
310 views

Custom Event System in C#

I'm currently writing a game and want to encode everything that happens (GameObject has moved, hp changed, was created/destroyed, got/lost a component, ...) in Events that look like this: ...
4
votes
1answer
298 views

Angular wrapper for SignalR event aggregator

I created a little wrapper for one of my JavaScript libraries to enable Angular functionality. Are there any pitfalls I should be wary of with my code? ...
1
vote
3answers
120 views

Update extremities losses when selected type changes

The following code works, but is it a good idea to call another method in a setter? ...
6
votes
1answer
186 views

GitHub (and Bitbucket) Pushing Events

This code is for dispatching and handling certain events from GitHub (and also Bitbucket). Things like pushes, issues, etc. can be handled by this system, and strongly-typed objects will be returned. ...
2
votes
1answer
1k views

Simple event emitter

I have written a simple event emitter in Python, which allows subscribing to events and emitting events (along with monitoring events too). I'm rather new to Python, and would like some feedback on ...
4
votes
1answer
63 views

Style-changing handler for an HTML drop-down box

How can I maybe do some loop that will compress the amount of JavaScript/jQuery I need to use. I have a function s3episodesChange() linked to a ...
3
votes
1answer
815 views

Event Aggregator Pattern Decoupling

I have an Android application that is using an EventBus architecture with publishing and subscribing events. Usually this is ...
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 ...
6
votes
1answer
17k views

Event-listener implementation

While writing a C++ GUI application more or less from scratch I needed some form of an event-listener system, preferably using lambdas. An event should be able to have multiple listeners and the user ...
-1
votes
2answers
231 views

Toggling class on mouse hover

I am using this code to add a class on mouse hover to a link button and remove it on mouse leave. ...
2
votes
1answer
3k views

Keyboard input class

I am looking for advice on my input component. There is no real problem with it yet, but I am just getting started on everything and want to know if there is any obvious problems with it, plus I was ...
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 ...
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 ...
4
votes
3answers
1k views

Subscribing an Object to its own Events

Is it appropriate for the class to subscribe to its own events like this? Should the class not subscribe, and instead move that code to before the ...
1
vote
1answer
112 views

Fast Event Manager

I've recently coded an event manager with performance as the main factor. I'd like to know what you think of it and what could be made better. ...
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)...
3
votes
2answers
151 views

Toggling html buttons and text

I went through a question on SO, and optimized the code according to OP's requirements. I would like a review if it is done properly or not. Here is the code snippet, there are 2 level buttons, when ...
4
votes
2answers
273 views

CheckChanged event readability

I have a CheckChanged method that I would like to improve as it takes a lot of space in my program and really hurts readability. The method prompts the user for ...
2
votes
1answer
96 views

Setting header color on scroll for each post

On this site this site, I have some code which you can see below which figures out the offset for each post from the top of the document and assigns a colour from each post to the header when it ...
6
votes
2answers
98 views

Handling calculator keypresses

I've added decimal (floating point) functionality to my calculator implementation; it's working but I'm having trouble making it more concise and less ugly. I'm trying to use the same method to ...
3
votes
1answer
664 views

Handling a double click issue

I've been doing a lot of form submission using Ajax now and being used to it than having a normal submission. What's been troubling me is that I always ran with a double submission issue when the user ...
6
votes
1answer
929 views

Detecting gyroscope data using promises

In a plugin that I am currently authoring, I am using a function to check whether the device provides gyroscopic data. Although intuitively this can be easily resolved by checking the value of ...
2
votes
1answer
762 views

Overriding scrolling behavior for navigation elements

I am new to JavaScript, and trying to ensure the i write the best possible code instead of "copy & paste". I hope i am asking correctly, want to know if my code I have written is done correctly ...
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 ...
2
votes
2answers
204 views

Toggling classes on many elements when a button is tapped

I have this very easy functionality to find, toggle and remove classes from my html elements. The thing is that I find my self repeating the same code with just different name classes. I basically ...
4
votes
1answer
3k views

Full screen countdown display

As a part of a bigger application, I wrote code which creates a display for a countdown of a given time. It is nothing fancy, but I would still appreciate a review. I am especially concerned about: ...