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.

learn more… | top users | synonyms

-1
votes
0answers
8 views

PHP Event library using Mediator+Observer pattern with best OOP practices [on hold]

I'm working on developing this PHP event library for one of my other projects to use. The code is fairly complete, but I have this nagging feeling that some parts of it could be structured better, and ...
2
votes
1answer
32 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
33 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
0answers
56 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
68 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 ...
3
votes
1answer
91 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
57 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
56 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
61 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 ...
8
votes
2answers
124 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
109 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
36 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
86 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 ...
3
votes
2answers
76 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
229 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
60 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
58 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
70 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
73 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 ...
1
vote
1answer
39 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 ...
6
votes
1answer
237 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
54 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 ...
3
votes
1answer
113 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
66 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
241 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
2answers
439 views

WinForm Calculator

I'm looking to get this cleaned up. ...
4
votes
0answers
279 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
57 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
45 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
724 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 ...
4
votes
1answer
117 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
274 views

Empty an array on focusout - jQuery UI Autocomplete

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

Object oriented rugby analyser

I have this code which mimics a rugby match. You select a player by clicking the div (turns green), move it, and click to release (returns to default color). There is a bug, the mouse can move too ...
0
votes
0answers
47 views

Pinch, swipe and doubletap/click prevention

Partly for fun, I wrote my own script to detect pinch, swipe and doubletap/click to be used on touch devices as well as desktops. It works OK, but there is always room for improvements, so any ...
3
votes
0answers
44 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 ...
10
votes
2answers
437 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
436 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
26 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
170 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
51 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
293 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
123 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
137 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
135 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
308 views

Creating a EventHandler class for buttons with different actions

I have the following code at the moment: ...
5
votes
2answers
501 views

Java MVC model for large scale GUI using annotations

I'm trying to make a good MVC model using annotations, which I will use it in a large scale GUI project. I want to respect the maximum of rules and guidelines, and be able to decorrelate every parts ...
3
votes
1answer
59 views

UpdateGame function for Tetris

I am writing a Tetris game while learning Haskell and I'm trying to make the following code more concise and easier to read. How can I improve it? Note that the function is not finished yet (There is ...
2
votes
1answer
153 views

ECS Event/Messaging implementation

I am experimenting with ECS design and I am looking for a solid way to implement a message bus for use between the different systems. Here is a stripped-down version of my current implementation: ...
2
votes
0answers
81 views

handle drag and drop operations

I've come up with the following code to handle drag and drop operation. It's composed of a constructor function that returns an objects with methods to attach to event handlers. Notes about this ...