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
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
4k 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
1k 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
623 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
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 ...
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
34 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
664 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
510 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: ...
5
votes
2answers
2k 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
130 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 ...
6
votes
1answer
2k 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
269 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 ...
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 ...
5
votes
1answer
2k views

Copy Cell on Worksheet_Change event if some criteria is met

This code is working fine, but it looks awful (yes, I am a rookie on this thing). How can I improve it to look better? ...
1
vote
1answer
67 views

Repetitive event handler for a toggling UI control

I feel like this bit of code could have been written more elegantly, especially with the huge if/else statements. Can somebody help me break this down? It would really help me out in the future. <...
6
votes
2answers
404 views

Is my Delegate defined the right way and does it need to transform to a pretty Event butterfly?

I have read so many bed time stories and ins and outs of how delegates work and why events are to be replaced with delegates (surely not all the time) and just couldn't get my head around it. I am ...
3
votes
1answer
6k views

Inactivity Timeout

I made this piece of code to detect inactivity on different aspects of my app. It is part of a set of pieces to analyze user behavior. Not saying it's ugly, but good looking constructive criticism to ...
3
votes
1answer
2k 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: ...
5
votes
1answer
2k 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
81 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 ...
4
votes
1answer
1k 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
47 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
223 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
122 views

Many onClick handlers that all append different text to one textarea

The script basically just appends the words based on the user's click/s on the textarea. I just need some help improving my code further using the ...
2
votes
1answer
2k 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 <...
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 ...
4
votes
3answers
579 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
93 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
5k 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
2k 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, ...
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 ...
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 ...
5
votes
2answers
1k views

Toggling between radio 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 ...
3
votes
5answers
92 views

Handing focusing and unfocusing of multiple form fields

Here is a link to my problem ...
1
vote
1answer
1k 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
2k 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 ...
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 ...