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
3
votes
1answer
172 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
842 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
299 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
290 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
184 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
62 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
799 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
809 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
15k 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
220 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
125 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
427 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
107 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
579 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
272 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
95 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
631 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
912 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
730 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
621 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
191 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: ...
4
votes
1answer
107 views

YouTube video intro, and autoscroll when video ends

This code creates an intro video using the Youtube API, screen text written by JavaScript with a typewriter kind of effect. How can I rewrite this as succinct object-oriented code? Also, I'm not sure ...
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 ...
8
votes
2answers
3k views

WinForm Calculator

I'm looking to get this cleaned up. ...
5
votes
0answers
2k views

Reducing complexity in NSView event handling code in Swift

My Cocoa event code always tends to descend into madness, I need to advice on how to reduce complexity. I've spend a few hours putting this example together. CanvasView is a layer hosting subclass of ...
2
votes
1answer
2k views

Action Event and checking buttons

I am creating a simple program with multiple buttons. Is this way of checking which button was pressed is ok? Is it better to use switch..case.. statement? ...
0
votes
1answer
997 views

document click vs element click

I am wondering if the following is a good concideration. There might be several links on a page with a data-rel attribute that could be static or dynamically added with javascript. Instead of adding ...
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 ...
5
votes
1answer
590 views

Flexible generic event system that binds to objects

I have been trying to create an event queue system using SDL. I've been trying to use this for Pong. The game is not even finished yet, but I stopped work to examine how my event system is organized. ...
4
votes
1answer
2k views

Empty an array on focusout - jQuery UI Autocomplete

Is it good to empty an array on focusout? ...
4
votes
0answers
71 views

Comparison of sprite movement implementations

I've come up with two ways to do sprite movement with CreateJS, and I'm wondering if one is better than the other as far as performance and maintainability. The player data is saved in a json file ...
13
votes
1answer
23k 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 ...
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 ...
5
votes
1answer
3k views

Embarking on a Tic Tac Toe journey with JavaFX

On my educational trek through the capabilities of JavaFX, I thought it would be a valuable challenge to create Tic Tac Toe. It took me far longer than expected to get this far, but despite likely ...
1
vote
0answers
33 views

Hybrid event model - comments wanted

I've tried out a hybrid type of event management model, combining elements of the addEventListener-type and the onEvent-type. What I don't like about the addEventListener model is that you have to ...
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 ...
1
vote
1answer
63 views

Selection handler for color picker

At some point, I have this function which updates a color picker according the the mouse position, according to whether the user clicked a mouse button and according to its previous state: ...
0
votes
1answer
1k views

Multiple custom file input fields with jQuery

I've modified this example to better suit my needs in handling multiple custom file uploads on the same page. It also renders the filename or truncates if it is too long for each of the 3 file fields. ...
5
votes
1answer
650 views

Speed unit converter

I'm basically a newbie in android app developing. So I'm not sure if this is the right way to write these codes. I have made an app called "Zconverter". It has 9 fragments and the code i m showing ...
3
votes
1answer
471 views

Checking checkboxes

I wrote this code for checking checkboxes. There are two groups of checkbox: each group's checkboxes have one common class all_perks and one individual class ...
5
votes
1answer
2k views

Implementation of KeyEventDispatcher in Java

This is my first test at making a key event dispatcher. Some of the code is unnecessary if one is interested in separating lower and upper cases, however I want to treat them as the same. Hence my ...
5
votes
1answer
4k views

Creating a EventHandler class for buttons with different actions

I have the following code at the moment: ...