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
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
975 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
190 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
163 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
183 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
3k 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 ...
13
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
105 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
110 views

Reading keyboard input

This is how I read the keyboard in my game: ...
3
votes
1answer
173 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
324 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
786 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
645 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
207 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: ...
14
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
1k 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
5k 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
453 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
144 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
36k views

Very simple events implementation

I've been thinking about implementing events and wrote some abstract code: ...
5
votes
1answer
339 views

Two keyboard handlers for a video game character

The code below is equivalent. I can see pros and cons for both versions. Which is better: the short, clever way, or the long, ctrl+c way? Short version: ...
2
votes
1answer
63 views

Changing line colors and move text for menu navigation

This code basically changes the color of the lines and move text for menu navigation. Is there a simpler way of writing it? ...
1
vote
1answer
302 views

Haskell game loop with keyboard handler

This is function, that works correctly, but it seems to be too ugly. panel argument is never used for anything but pushing into ...
3
votes
2answers
125 views

jQuery plugin to detect Konami cheat code sequence

How can this be written a bit shorter? ...
5
votes
3answers
1k views

Replicating C#-style events in Java using reflection

For something I'm doing, it would just make things so much easier, quicker, and cleaner to have C# style events. I've written a class I believe should replicate a C# style event using reflection. ...
4
votes
2answers
257 views

Handling a dragging gesture using jQuery

I'm not sure if this is the right way to do this, but I want to simply this script and hopefully use CSS3 animations. The code is really large, and parts are very irrelevant, so I'm wondering if I ...
3
votes
3answers
12k views

Simplifying multiple mouseover and mouseout functions

I am trying to hide and show tooltips depending on what element is hovered over. This works as expected and I could continue to rinse and repeat. However, I am wondering if there is a good way to ...

1
5 6 7
8
9