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
votes
1answer
47 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
193 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 ...
6
votes
2answers
742 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 ...
0
votes
3answers
496 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 ...
4
votes
1answer
1k 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
1k 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 ...
3
votes
1answer
4k 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 ...
4
votes
1answer
77 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 ...
2
votes
1answer
3k 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: ...
4
votes
0answers
915 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: ...
4
votes
2answers
85 views

Initializing events on class

I wrote a simple class that substitutes all file inputs in an HTML for a more complex template and set some actions on it. The code is rather small, but I'm not used to write JavaScript. I wonder if ...
5
votes
1answer
3k 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 ...
3
votes
2answers
188 views

Lots of click handlers that hide one element and show another

I've a lot of code blocks that hide/show some block. ...
6
votes
1answer
1k 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. ...
6
votes
2answers
161 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 ...
4
votes
1answer
9k views

FileSystemWatcher firing multiple events

Like others (FileSystemWatcher Changed event is raised twice) I am facing the problem that events of filesystemwatcher are ...
7
votes
1answer
175 views

My EventBus system

I decided to roll out my own EventBus system which is intended to be thread-safe. Hence a review should focus extra on thread safety apart from all regular concerns. The ...
5
votes
1answer
2k views

Having children call parent's public events with data generated from a protected event

I don't know that my title describes the code I want reviewed. Hopefully the code is explanatory. I have an abstract parent class with two children. The parent listens to some hardware notifications ...
12
votes
3answers
4k views

Simple event management system

In an effort to rid my code of jQuery, I wrote a custom global event management/handling system. I was expecting this to be hard as, from what I've read, most people don't create their own. It's far ...
2
votes
1answer
103 views

Can this architecture of base + derived classes be coded more efficient? [closed]

I've got some architecture in my code similar to this. It is about the Construct method in the base class in the example below. This method contains the logic for constructing a building, which is the ...
3
votes
2answers
2k views

Registering multiple keypresses simultaneously, very slow

I'm working on a Pong game and right now I'm working on being able to register multiple KeyDown presses simulatenously. I used the Win32 native method ...
2
votes
1answer
105 views

Reading keyboard input

This is how I read the keyboard in my game: ...
3
votes
1answer
171 views

Thread Safe Events while utilizing EAP

This is my code for a server using EAP (Sockets). Is AsyncOperation.Post the right way to raise thread safe events? ...
6
votes
1answer
4k views

Correctly implementing the Swing TreeModel

Ideally the Code Review would target the correctness of the approach implementing the Swing TreeModel. In particular, is the structural separation[1], event message passing, threading[2], object ...
4
votes
1answer
3k views

Preventing keydown delay

I created a class to prevent the default delay which happens when holding down the key on Windows Forms. It seems like the class is working correctly but I don't know if I'm using the best practice. ...
4
votes
1answer
314 views

Event Handling system in Java - follow-up

This code was already reviewed, but the reviewer missed many points of my code. Most of the following question is from the previous review. I have written a system for handling the dispatch of events ...
7
votes
1answer
6k views

Event Handling system in Java

I have written a system for handling the dispatch of events between objects. (I need this functionality for a larger project I am working on. Objects should be able to dispatch events without knowing ...
2
votes
1answer
88 views

Auto change page title while bookmarking a page

Here is what I'm trying: Please review the code: ...
3
votes
1answer
4k views

Bootstrap/bind click event over ngClick

I am working on angularjs, and I have created some directives with bunch of HTML elements within its templates. I have assigned a controller for those directives. Below is my code snippet: ...
6
votes
1answer
784 views

Generic event class - am I over-complicating it?

I'd like some advice about any better or cleaner way to implement this class, if there's any. I made it using this answer, posted on Stack Overflow, as reference. A lot of problems arose when I ...
2
votes
1answer
78 views

Proper techniques for allowing many views to subscribe to window.unload?

I would like to execute code for many views whenever the window is unloaded. For instance, I could have something like this in a view's initialize: ...
6
votes
3answers
4k views

Mouse input handler which exposes read-only mouse state data

I have a MouseInputHandler class that registers itself to an InputManager. When the InputManager class receives events they are ...
4
votes
2answers
1k views

Get array of pressed buttons using extension method

In my game, I need to detect whether any buttons/keys are pressed at all before I try to process any input. This is easy enough for keys since the XNA library provides a ...
2
votes
1answer
1k views

MVVM implementation using C# and XAML

I have used INotifyPropertyChanged for both Model and ViewModel. Is it correct? First of all I was trying to use ...
8
votes
1answer
2k views

How can I condense several IBAction methods in a class with a delegate?

I have the following class: MyProtocolClass.h ...
2
votes
1answer
73 views

A class for dynamic inputs

This class creates dynamic input labels. You give it a pair of elements and it sets up the event listeners and CSS toggles to accomplish this. Looking for feedback on code structure and correctness. ...
3
votes
1answer
636 views

Optimizing a very simple wpf app - attempt on handling 2 buttons with a common event

I am quite new to event programming in C# specially in WPF. I have made a very simple core app which I am planning on extending. It's very simple as its purpose is learning curve and doing things ...
2
votes
2answers
194 views

JavaScript custom addEvent function to add event handlers

I'm learning JavaScript and I was trying to make a custom addEvent function that would care about compatibility (I don't want to use jQuery [nor any other library] yet, in order for me to "master" the ...
2
votes
1answer
2k views

“Enter key pressed” event-handler

I am writing an "Enter key pressed" event-handler, so when user presses the "enter" key in the input of type text, this code is called: ...
13
votes
1answer
5k views

My Event-handling system

I have written about 180 lines of code that implements an Event system. I would like a general review about the code and I'd love comments about the usability of it. (Is the code useful? Would you ...
3
votes
0answers
121 views

Encapsulating behavior spread across multiple event handlers

I wrote a chatbot in Ruby for turntable.fm, a chatroom where users can listen to music together. It interacts with users in a room, who can type in specific keywords and get responses from it. It also ...
4
votes
1answer
2k views

Event handler using variadic templates

I am currently working on a game and found myself in need of an event handler. I wrote an event handler similar to this one some time ago, but decided to update it using variadic templates (this is ...
2
votes
2answers
974 views

Sensing when a network is available

The code below just senses when the network is available and enables/disables a button on the UI. If I am registered to the NetworkAvailability event for the life ...
4
votes
0answers
3k views

Event system using callback functions in C++

I am learning C++ and have been trying to create an event system for use in a small game. This will be the mechanism by which game entities communicate. I would be eternally grateful if someone with ...
2
votes
2answers
5k views

Designing an EventHandler in C++ [closed]

I am writing a simple event handling class in C++, to avoid having delegate registration and calls cluttering the rest of the code. I have a design that seems to do the job, but it has a couple of ...
2
votes
2answers
4k views

How to observe nested objects

By having two model classes Conversation and Message, what are the best practices to handle the next situation: A conversation ...
6
votes
2answers
412 views

Shopping cart using events and delegates

I am trying to learn events and delegates in C#. To do that I am trying to create a hypothetical console project where when some user submits the orders in his/her shopping cart, I need the Billing ...
2
votes
2answers
143 views

Placeholder text for HTML search field

I'm not a great JS coder so I need your expertises to look into my code (although nothing very special and it works fine) to see if it is good practise or not because I heard that dodgy JS coding ...
2
votes
1answer
15k views

Attaching both mouseenter and mouseleave event handlers using jQuery

I'm a newbie to javascript, and day after day, I try to write better code with jQuery. For example, I wrote this code earlier: ...
4
votes
3answers
35k views

Very simple events implementation

I've been thinking about implementing events and wrote some abstract code: ...