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

3
votes
1answer
28 views

Invoking only the last registered event handler

We are building a game and we have a dialog system. Dialogs may open and stack on top of one another. When every dialog opens, it registers itself to handle the BackButtonPressed event: ...
4
votes
1answer
70 views

Closure as UIControlEvents handler

I'm expanding the functionality of this SO answer. Mainly I'm focusing on: You can add as many handlers as you want. You can remove (i.e. cancel) the handler. You can receive the ...
5
votes
1answer
38 views

Synchronization Event with awaitAny

In Java, there is no way I know of to wait for multiple events at the same time (see Stack Overflow). Since I would like to use that feature (similar to ...
3
votes
0answers
33 views

Asynchronous API calls with delegates and event handlers

I'm making a WindowsPhone 8 app in C#. With this an API so I can convert JSON data into useful objects. I've found a method but am wondering if it is any good at all. The problem is it's been a while ...
1
vote
1answer
30 views

Adding classes with JavaScript

I am working again and got this to work. Is this the best way to write this code? ...
2
votes
3answers
128 views

Loop termination check for multiple types of host reachability tests

I have 2 booleans: host.isReachableOnLan, and host.isReachableOnWan I have a listener ...
2
votes
1answer
31 views

Many onClick handlers that all append different text to one textarea

Hi this code works fine as it is, I just need some help on improving my codes further using the .on("click", function{}) and if possible can this code be shortened? ...
2
votes
1answer
36 views

Using a List to manage Swing event listeners

I've been playing with an idea for simplifying management of event listeners on custom Swing components. Swing provides the EventListenerList class for maintaining events, and every JComponent has a ...
6
votes
1answer
58 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 ...
4
votes
3answers
114 views

Click handlers for two to ten buttons

I have click event handlers for two buttons. The code is working well, but I want to apply the DRY principle. How should I rewrite the following code in the button_click event handler so that I don't ...
2
votes
1answer
33 views

Detaching logic from listener implementation in “Smart UI” approach to follow a proper pattern

I took this code segment from existing source on Android, but it applies to anything from ASP.NET Forms to anything else where the UI has an event callback, and the logic is implemented directly in ...
2
votes
2answers
114 views

Optimizing jQuery addclass / removeclass on scroll

I have a scroll event and add class and remove classes for different elements. As you can see the code is a bit big. Is this method ok or is there a more efficient one? I mean, you can see that there ...
6
votes
1answer
84 views

Navigation bar built from fetched JSON data

I have finally been able to create my little navigation plugin in an object-oriented way that reads the li from a JSON file. Now, is my code efficient? Especially, ...
6
votes
1answer
70 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 ...
6
votes
1answer
85 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 ...
5
votes
2answers
209 views

How can I refactor onClickListener applied to different buttons?

I have several buttons and I want to toggle between them like radio buttons. The way I have it set up now is that each button have this same code but the buttonValue varies depending on which button ...
3
votes
5answers
48 views

Handing focusing and unfocusing of multiple form fields

Here is a link to my problem ...
1
vote
1answer
74 views

Is this use of JavaScript prototype functions for attaching event listeners going to meet design goals?

Please provide a sanity check on my below JavaScript pattern to be used for a custom edit control. The goals are: Centralized code Avoid name collisions Minimize memory use (putting functions on ...
5
votes
2answers
110 views

Extension methods for safely firing events

I wrote a set of extension methods for the EventHandler class that add the method Fire, which raises the event after creating a ...
8
votes
5answers
2k 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 ...
3
votes
1answer
52 views
2
votes
0answers
34 views

Synchronous event library

I have implemented a small library that handles synchronous events with POSIX-compliant threads. I have oriented this with the already existing POSIX thread API. Here are the files I created: ...
10
votes
7answers
848 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 ...
3
votes
1answer
110 views

Toggling element class according checked radio input V2.0

This question is about an improvement of the code from this previous question (previous changed visibility, new applies a CSS class with a border). It is a constructor function that attaches a click ...
6
votes
2answers
80 views

Android audio player

I want to implement basic audio functions like play, stop and pause. I have stuffed all the code inside onCreate method. Is this best practise to follow? ...
3
votes
1answer
66 views

Refactor three state button

I have a button (or icon) which can have three states. On hover, it changes state and on click, the new state gets transferred to another state. This state is kept until you click again for which it ...
3
votes
2answers
63 views

Compact jQuery tool tip code, without jQueryUI

I have this tooltip code that I came up with, using jQuery: ...
5
votes
2answers
250 views

JavaScript onKeypress validation

This is a function for JavaScript validation: ...
5
votes
2answers
120 views

Messy handler for multiple touch events in a game

I have mobile game that has a handler for touch events. What it does is: main function that get the touch loop in module A all sprites check if the touch coordinates are in the boundary of one of ...
2
votes
1answer
98 views

Best way to handle tap gestures

I'm building a small web app primarily for mobile use. I have some widgets that need to handle tap gestures in the expected way, and I don't feel this one feature is reason enough to include JQuery ...
3
votes
2answers
97 views

Is this too much work for 1 listener?

Is this too much work for 1 touch listener? Is this bad for devices with slow CPU's? ...
3
votes
1answer
88 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 ...
3
votes
1answer
57 views

Recognizing elements and doing event handling for repeating templates

This fiddle has an ADD button when you click it a Chat window is added. When there are more than 1 windows the message from one window is reflected across all the windows. Say you have templates (in ...
10
votes
5answers
1k 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 ...
1
vote
2answers
99 views

Menu selector code that changes the background of a selected div

i made this code to change the background color for a div in set of divs while disable the rest divs background it work fine as it look but i wanted to review the code for more improvement since I am ...
0
votes
1answer
36 views

Touched events created in a for loop [closed]

All I want is a simple "yes/possible" or "no/and that's bad coding". I have a card game I'm making and looking through your discard pile is a big part of it, so it's going to be constantly growing. ...
6
votes
2answers
115 views

Scroll listener - about code style guidelines and standards

I'm an upstart, been only professionally programming for a bit less than 2 years, mainly in Java as I am currently working as an Android developer. I often find myself thinking about how to improve ...
5
votes
2answers
134 views

Small jQuery mobile plugin to handle touch events

Why this plugin: I am developing a mobile app - at some point, I felt like this would be a good idea to give the users the possibility to control everything in the app with touch gestures, hence the ...
3
votes
1answer
80 views

Should I null coalesce EventArgs?

When I implement events, it usually looks something like this: ...
2
votes
3answers
103 views

Does this function have to be nested?

Recent JavaScript student here. I ran afoul of some weirdness with event listeners that led to my code being unresponsive. After some reading and tweaking, I arrived at a version that worked in ...
2
votes
0answers
146 views

Possible memory leak with WPF Custom Control?

I might have a potential memory leak with my custom control. Do I actually have one? ...
2
votes
2answers
153 views

Creating a function when user clicks on element to toggle another element

I use a lot of "when user clicks on element then another element will be displayed as visible/hidden... aka toggle". So I'm trying to make a general function to abide the DRY principal. Before ...
2
votes
1answer
325 views

Enabling/Disabling button on a certain condition

I am using a Telerik Datetime control. On onBlur event of input box I am checking if the date is valid/in-valid, based upon that ...
2
votes
1answer
52 views

Which mouseover handler is better?

I'm currently learning some jQuery and I am stuck on something. On a small exercise I did, I was asked to perform an action when you mouseover a div class. I gave a different solution than the one ...
1
vote
0answers
435 views

Keeping WebBrowser control's DocumentCompleted event handlers

This morning, being in urgent need of an effective subject code solution, I have had to write a "quick & dirty" custom one: ...
3
votes
0answers
63 views

Anonymous Events in Delphi

I wrote a anonymous event creator. I would like to ask if anyone can tell me if I did it the "right" or "best" way, or how I could make it better. Here is what I did: Declaration: ...
5
votes
1answer
895 views

MouseListener Lag in Piano Tiles game

I was attempting to write my own simple version of the Piano Tiles game app in Java just as a fun exercise. GameLogic.java ...
6
votes
1answer
332 views

Is this Android click handler using threads correctly?

I am implementing a thread like the following. Is my implementation correct? It works well, but I need a check. ...
1
vote
0answers
319 views

Hide element when clicking anywhere but some elements using jQuery

I had a jQuery program that displays some hover-over messages when touching an icon, in order to make it disappear the user needs to click again in the icon. ...
6
votes
2answers
111 views

My EventBus system followup

This question is a followup from my previous question My EventBus system, and incorporates most points from @rolfl's answer. It includes, but is not limited to: Usage of ...