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
1
vote
2answers
654 views

Many event listeners

Is there an alternative possibly cleaner way (without so much repetition) to write the following? I'm thinking about the headache it's going to be when I have to remove all of my even listers. ...
2
votes
0answers
214 views

Generating a carousel slider

I'm currently using Backbone to generate a carousel slider. In my View, I have an initialize function that looks like this: <...
2
votes
1answer
91 views

Passing object back to Windows Form button event

I have windows form application. One button event starts the script via object called ScriptStarter. The status of object is used to pass message and color to UI (toolStripStatusLabel1). I'm not sure ...
3
votes
2answers
810 views

Callback system for events in a window

I have written a simple window event capture wrapper that gets events that happen to the window, and can be checked anywhere in the program through a global class. I wanted to be able to create a ...
4
votes
1answer
2k views

Custom event handling system

I'm relatively new to C++ (learned it years ago, but never used it much until now), and I needed an exercise to get a better handle on the language. I also needed a good way of handling events, and ...
4
votes
1answer
132 views

Basic C# R-E-P-L

So I was thinking of making a C# REPL, as I didn't find any viable solution that would work for me, so I made a simple, basic one, I am sure it can be improved, as it seems once the REPL class is ...
2
votes
1answer
153 views

Removing same event from listener

I have a myDiv.mousedown, window.mousemove, and window.mouseup event. I'm trying to organize ...
5
votes
1answer
14k views

Communicating upwards from nested fragments in Android

I recently asked this question on Stack Overflow, but now that I have a working example, I would like to have it checked. I set up the layout like this: I am going off the idea that parents can talk ...
3
votes
1answer
5k views

TabPage version of SelectedIndexChanged

I order to speed up opening of a file (which contents are displayed in a series of tabs), I made it so that tab content is generated only when the user first clicks on the tab. If user never opens the ...
3
votes
1answer
261 views

Using a MutationObserver to reformat numbers in the user's locale

I mostly just want to make sure I've understood the specs correctly with this code, but here goes: ...
5
votes
1answer
2k views

Simple event manager in Java

I have created a simple event manager and I want it to work properly in a multithreaded environment: ...
1
vote
2answers
3k views

Use jQuery to force two checkboxes mirror each other's state

RESTRICTION: jQuery 1.6.4 only, no other library, or version can be used. My goal is to use jQuery to allow two input checkboxes behave the same. For example: If 1st checkbox is checked, 2nd will be ...
2
votes
1answer
443 views

Client Side JavaScript [aka Greasemonkey] Key Event Handler

Description The code captures keypress events that do not occur in a text field and dispatches on the properties of a $command object in the application execution ...
4
votes
1answer
100 views

Swing Game EyeHandCoordination

Question copied from the book: (Game: eye-hand coordination) Write a program that displays a circle of radius 10 pixels filled with a random color at a random location on a panel, as shown in ...
3
votes
1answer
216 views

Make one greenlet tell another to shutdown

I am building a commandline app to check proxies, which has a daemon flag (running forever or just once). There are producers, checkers and storers. I want them to run in parallel and be able to ...
0
votes
1answer
147 views

Highlight Two Closest Points Java Swing

Question from the book: (Geometry: closest pair of points) Write a program that lets the user click on the panel to dynamically create points. Initially, the panel is empty. When a panel has two or ...
1
vote
2answers
201 views

CRUD code for a finance WebForm

I have a finance web-application in ASP.NET WebForms using Telerik RAD controls. Two event handlers wound up being very similar in implementation. What steps could I take to improve the organization ...
0
votes
1answer
81 views

Wait for a “3rd party” element to be appended to the DOM

Let's say we're writing a user script which interacts with a 3rd party site we don't control. We want to open a menu, so we trigger a click on the button and then wait 10ms before accessing the menu (...
2
votes
0answers
430 views

Swing keybinding to control an animated car

In my textbook there is no mention of keybindings and it encourages the use of keylistener so there isn't any example code using keybindings for its problems. I was wondering if this is sorta close to ...
3
votes
1answer
55 views

Event-triggering - Ready, On, Fire

I have implemented a kind of thing that does event triggering in Golang. This is open-sourced here. Review and suggestions appreciated. First thing I am trying to implement is adding event listeners ...
4
votes
1answer
1k views

Google Analytics tracking for HTML 5 video player

The jQuery code is for html5 video event GA tracking and I want to make it a little bit more shorter and cleaner. The code works: I am getting all the events, but would like to make it more simple. <...
1
vote
0answers
3k views

An event bus implementation for java

I have implemented an event bus library for Java - JBus. Anybody please care to review my code? It is an open source project and link is provided above. Usage Define events: ...
25
votes
1answer
52k views

Use of Async/Await for EventHandlers

I have a MVC WinForms application. I am using Dependency Injection with Ninject as the IoC container. ...
3
votes
0answers
45 views

Simple gallery with scroll

I just created a simple gallery with scroll. Everything works fine but I'm not sure how should I optimize this code: ...
1
vote
0answers
748 views

Simple Pub-Sub Event Emitter

I have written a basic event emitter in JavaScript and I'd like some feedback on my design. I tried to make it as simple and minimalist as possible, as I'd like it to be understandable by anyone. I ...
3
votes
1answer
41 views

JavaScript idle managing structure

I am just getting into the world of javascript, coming from the world of classical inheritance. The following is a library I wrote to track when a webapp is idling and I wrote it like I write ...
1
vote
1answer
145 views

Java application processing GUI input when “Done” is clicked

Right now, I've got this really ugly loop in my code that waits for a boolean to be true before the method can return. It's triggered when "Done" is clicked. I'm ...
3
votes
0answers
717 views

C++ Event Emitter

I needed an event bus in C++ with a few features: Possibility to add/remove both functions and member methods. Ability to remove automatically those listeners that wrap member methods of expired ...
2
votes
1answer
2k views

Simple type-safe and thread-safe Rust event system

I'm creating a relatively simple type-safe and thread-safe Rust event system. It is to be used with and within an IRC library I'm making, but should work just fine for other use-cases. It needs to be ...
1
vote
2answers
395 views

delegate click event on document

I'm adding an onclick listener to the whole document then checking the source of the click. If the source of the click contains the attribute data-widget I want to ...
9
votes
2answers
2k views

Recorder for keyboard and mouse events

I'm building an event recorder. So far the code looks clean, but I feel like I'm missing something that can make this code even better. Is composition a better solution? If yes, how can I do it ...
1
vote
1answer
28k views

Focus next element on keypress

It's been a year or two since I last dabbled in jQuery and have attempted to write a simple "on key press move to the next element" script. However my first attempt has a lot a repetition. I just ...
2
votes
0answers
342 views

Event Service in c++

I'm interested in receiving some feedback regarding an Event system that I wrote. Both in style and implementation, but also in overall design and the design decisions that I made. It is intended to ...
4
votes
1answer
971 views

Event delegation without jQuery

I created event delegation like concept which is present in jQuery. AFAIK, event delegation is used to register an event for an element which is supposed to be added dynamically. So, in jQuery we do ...
0
votes
2answers
255 views

PageVisibility API, to handle page/tab visibility changes

Currently, I'm working on a project where I needed to run some code every time the page is hidden. I searched high and low and found this question: Is there a way to detect if a browser window is not ...
2
votes
0answers
221 views

Event Delegates using IIFE or Module

I am learning jQuery/JavaScript best practices and am attempting to put them into practice. My overall goal is to have lots of small, independent .js files which contain specific functionality and ...
9
votes
2answers
7k views

Yet another event dispatcher in c++11

I've written an event dispatcher for a private project which task is to collect events from different threads and dispatch them in a single thread: ...
2
votes
1answer
149 views

Overriding the mouseout handler for an image when a button is clicked

I had posted this question in Stack Overflow and they told me it would be better served on Code Review. Is there a more effecient way of changing the mouseout state when a button is clicked? When a ...
3
votes
1answer
5k views

C++11 event system

I've implemented an events system in C++11. I've now got it pretty much as good as I can get it. It feels like I have found an optimal design pattern, and I'm using sensible variable names to ...
1
vote
2answers
65 views

Keyboard handler for moving in four directions

I'm having trouble deciding if I should leave the default: break; in the switch statement or not. It does kinda show intent, i.e. that most keys are not handled, ...
1
vote
2answers
83 views

Keyboard handler to move a shape in response to arrow keys

I finished Codeacademy and I'm looking to practice and get better at JavaScript. Is this coded correctly or should I have made a function for it somehow? The purpose of this code is to move a square ...
2
votes
2answers
738 views

Keyboard handler for selecting radio buttons

I have got my JavaScript working as seen here: https://jsfiddle.net/yLg1qs04/3/ But how do I condense/shorten it so that it's not repeating itself so often and taking up so many lines? ...
6
votes
2answers
1k views

Type-Safe Event System

I have recently started writing C# from a strong JavaScript background, and found myself wanting to do something I do all the time in JavaScript: events. Since I have a type system at my disposal, I ...
5
votes
1answer
5k views

Unit test if an event has been raised or not

Given the following event dispatcher code ...
3
votes
2answers
8k views

Raise an event (sample 1)

I'm writing tutorials for new programmers. The tutorials show programmers how to structure events. I've attached the code for one of the tutorials. Can someone take a look at my code and let me know ...
11
votes
1answer
2k views

C++14 Event System

I've created a simplified event system for C++14. The code is commented, so it shouldn't be hard to read. There's also a simple usage scenario below. It is still a work in progress and uses some not-...
3
votes
1answer
7k views

Removing all delegates from an event dispatcher

Given a class which is an event dispatcher whose underlying store is a dictionary of events whose key is the event type ...
2
votes
0answers
63 views

Alternative to clicklistener inside an anonymous class

For a trivial word game, I wrote the following code for the player to choose one of the two choices of words that in turn were read from a sentence. My question lies in first in the click-listener of ...
5
votes
2answers
602 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
41 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 ...

1
3 4
5
6 7
9