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
595 views

Simple event dispatcher

Here is my very first event dispatcher. I would like to get both, style and code review, as well as some ideas to improve this implementation (new features etc.) I tried to write code in C++17 style ...
3
votes
1answer
44 views

Lightweight Java Event Handling Interface

I've been looking for a simple way to manage event passing between classes and, like many others, have found the whole addXxxxListener paradigm to be tedious and ...
1
vote
0answers
286 views

Using postMessage() in JavaScript with iframes for cross domain communication

I am trying to enable communication via JavaScript from an iframe and its parent window when they are on different domains. I did a lot of research and it turned out that ...
1
vote
1answer
114 views

JavaScript debounce function

I built one JavaScript debounce function. I need a JavaScript expert's opinion if this is the correct way to do it, and if not, then what the flaw is in this current function. ...
2
votes
0answers
548 views

PyQt frame which changes color with child focus

I am working on an application that has various "panels" contained within splitters. I wanted the panel border to change color when one of it's children gained focus. Here is a simple example of the ...
3
votes
1answer
69 views

on() event handler for multiple objects [closed]

I'm using three instances of ace editor in a form. I initialize them like so: ...
0
votes
1answer
736 views

Handling keyup events with throttle or debounce in Javascript/jQuery

In my web application, there is a search input field, and when the user empties all of the text inside the input field, there is an API call made for a default-list of results, which are displayed in ...
2
votes
2answers
83 views

Manipulating the browser history

I created a table with the ability to edit with popup. This part of the code, which includes: the ability to send URL to other users with the subsequent opening of the same state (the popup window ...
3
votes
0answers
183 views

Media player subtitles in WPF - Part 2 Handlers and notifications

This is a continuation of Part 1. In this question I will present you with a single class which is the most crucial component of the whole system, it's responsible for firing notifications whenever a ...
5
votes
2answers
722 views

One more C++ event system

This is an event system implementation for C++. GitHub I'm targeted on following features: RAII-friendly any number of event parameters ability to use member functions, free functions and lambdas ...
1
vote
2answers
255 views

C# style Event and Delegate in C++

I'd appreciate advice regarding both the implementation detail and ways to improve usage/performance/generic. There are two parts: XDelegate, which is I got from ...
4
votes
2answers
13k views

Binding a keyboard key to a Tkinter button

I'm specifically asking about binding a keyboard keystroke to a button in a GUI. Originally I planned to bind the keystroke to the GUI button itself, but that seemed impossible, and potentially unwise ...
0
votes
2answers
84 views

Attaching a click handler in a cross-browser way

I have been attempting to have a method call, with a parameter, inside of a ternary operator to simplify some code. Code: ...
1
vote
1answer
115 views

Custom observable types and their supporting classes

I decided that for some parts of my project, communication through events would be very handy, for that purpose I started writing the most basic part of the event system, an interface consisting of ...
5
votes
1answer
494 views

Complete ObservableDictionary

In conjunction with a recent question of mine, I found that an ObservableDictionary would be very handy for my situation, so I decided to implement one. I've ...
1
vote
1answer
5k views

onChange vs onKeyPress for input in React

I have an input form, and when you press enter I want it to call a function. I was wondering what "the right" way of doing this is. Right now I have an input looking like this: ...
6
votes
1answer
187 views

Simple color clicker game

My friend recently made a color clicker game, and I tried cleaning up the code a bit. I want to know how I can improve the functions and passing/editing of global variables. There are a lot of ...
4
votes
1answer
156 views

A C#-style Event object in C++

I wanted to make an Event object (similar to C# events) for use with a custom UI I'm writing. The Event should allow multiple consumers (observers) to attach to any given event and not leave dangling ...
1
vote
0answers
39 views

Competent addition of events in JavaScript

I want to write my own library. The main class in it is Event. It performs a lot of hard work. I want to make it so that the programmer, using this library, could ...
6
votes
1answer
1k views

Simple implementation of signals and slots mechanism using templates

I tried to implement a simple signal&slots mechanism for some DSP software that runs on embedded Linux. I would like if somebody can review this code and give me some guidelines. Any review and ...
1
vote
0answers
709 views

Autosave reactive forms

I'm building an autosave for a data driven form on Angular. Here is our code snippet: ...
0
votes
1answer
42 views

Mark a radio element as selected on page load and when clicked

I have the following javascript that calls a function on page load and on click of an element on my page. Is this the cleanest way to do this? ...
2
votes
2answers
82 views

addEventListener after fetched data

This is working code, but I want to simplify, correct, and improve the code. ...
1
vote
1answer
129 views

Async database helper function in TypeScript

I have made an async function in TypeScript that responds to Events and returns an object with methods that return a promise. I ...
1
vote
3answers
650 views

Hide or show table rows as a hierarchy

I'm using PHP HTML and JavaScript to write questions that need to be shown/hidden based on inputs from the user. I have several rows in a table, each row contains a ...
1
vote
1answer
81 views

Emit different text and sound when each of three buttons is pressed

I would like to use this same code on multiple pages of photos (to help my son recognize people). So instead of reinserting the name of each person, I created the ...
0
votes
2answers
52 views

Note which colour button was clicked

I have a script that changes the colour, it selects the colour by the id, then it listens what colour was clicked, and if the colour choose was black or whatever other colours, it will do the job. ...
0
votes
4answers
190 views

Three clickable navigation elements, where only one should be active

I have three clickable <h1> elements in the nav bar of a static page I'm making as a practice project. I wrote code so when I click one, it lights up. Since ...
2
votes
1answer
198 views

GLFW simple event handler

I wrote a simple concept of an event system in cpp. It is uses a namespace and a global state, but normally a global state with namespaces is bad practice. Is there a better way to do simple event ...
1
vote
0answers
261 views

Find delegated click handler for any DOM Node in the event path

I've got this method in a class that searches the graph of DOM nodes above an element for a click handler attached with Blaze or ...
-1
votes
1answer
27 views

Passing an event in a class instead of the whole class, in order to subscribe to the event [closed]

I am very green when it comes to working with events in C#, so I had come up with a custom example console application to familiarize myself with the syntax of them. I have this example working in its ...
2
votes
1answer
4k views

VueJS to do list - handling clear event on input

I made a basic to-do list in VueJS, but it feels really clunky and obtuse to me. One of the key things is that if the text input value is empty and the user clicks the button labeled submit then it ...
3
votes
1answer
205 views

Function to trigger animation with mouse wheel events

I am new in the JavaScript world and I just want to know if I can optimize my function by making it shorter. It already works but I plan to add five timelines to trigger with my slidenum variable. ...
2
votes
1answer
64 views

Vue.js code to update selection on screen

I have the following code snippet: ...
3
votes
0answers
298 views

Media player in WPF - Event binding

I recently started making a media player, this is the first time I'm using WPF and I found that most project are utilizing the MVVM architectural pattern, I haven't used that one either but I decided ...
1
vote
2answers
52 views
2
votes
0answers
178 views

Search GitHub users when text field changes in Kotlin Android app

Problem: Search for users by their name using the GitHub API (sorted by the number of followers) and display the results in a RecyclerView. Implementation: Hitting the GitHub API every time when user ...
6
votes
1answer
659 views

Signals & Slots implementation using Templates

I have written this code to handle events in my game engine. I guess the naming was inspired by Qt Signals & Slots, though I have never used Qt before. It might be similar. Anyways, I think it ...
1
vote
1answer
266 views

Domain events in the unit of work pattern

I've used the unit of work pattern to wrap my business logic. (Note that the application has three states: Logedout, LogedIn, Loaded) ...
1
vote
1answer
445 views

Replace HTML input file element with custom styled button

I've been working on a solution to replace the HTML input file element with a custom styled button. jsFiddle: https://jsfiddle.net/Lau1989/4jLz04pc/5/ First ...
8
votes
2answers
1k views

Javascript typehead using debounce

This is the code I wrote for making a JavaScript typeahead/autocomplete, which displays cities based on the user input. It would be great if you could suggest some improvements on the code quality. ...
4
votes
1answer
842 views

Event handling attempt using some of the c++ 17 features

I am messing around with the idea of event handling. What I tried here is to make an event handler that offers: type safety no need for a paired call to ...
2
votes
0answers
40 views

Event handler re-use in Javascript

I've been trying to deal with a lot of duplicate code in the first web pages I've been working on and have been playing around with the prototype model, which I think is the 'right' way to go about it....
2
votes
1answer
4k views

Angular 2 window service that listens for 'click away'

This is the angular service I wrote window.service.ts. ...
1
vote
1answer
1k views

C++ event system

I created a simple C++ event system. In my code Event_channel is a static class that wraps singletons that manages events per event type basis. Every singleton ...
2
votes
0answers
23 views

Event based read and output file lines

In the near future, the app will have to start several actions after having read the content of the file (executing request based on the request module). I was ...
8
votes
3answers
945 views

Mask latitude text field

I have an input element on one of the pages. This input is supposed to take a string of digits from a user. In order to enhance UX I'd like to mask input's value at any given time. Like so: What came ...
2
votes
0answers
56 views

Two similar methods to re-create objects and emit events

I have these two methods basically doing the same thing: ...
2
votes
1answer
82 views

Create a GUI to update parameters of an Object

I have an Glob object which represents a glob of data. It has several parameters like size, the date it was created, who created it, and so on. I'm building a GUI ...
2
votes
2answers
70 views

Enabling or disabling buttons on certain events

I need to run the following checks in two occasions: When a certain modal is first shown or clicked, When one of two inputs is filled. How can I remove redundancy in the following code? ...