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
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
6k 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
122 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 ...
6
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 ...
3
votes
2answers
6k 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
484 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
146 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
37k views

Very simple events implementation

I've been thinking about implementing events and wrote some abstract code: ...
5
votes
1answer
342 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
64 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
341 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
133 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 ...
4
votes
1answer
869 views

Cross-browser double form submit prevention

We developed a potential solution for the double form submit prevention and we need some review on it. To be able to execute this code on asp.net we needed to add our function call directly into the <...
0
votes
1answer
3k views

Change URL on select change

I've made a method, which inserts a new query parameter, when the value of a select changes, then reloads the page. I've had enough of URL jQuery hax, so I figured it would be a great idea to put the ...
2
votes
3answers
606 views

Options with a “yes” or “no” radio button

I have about 6 of these, but I'm only posting two. Essentially I have a bunch of options with a "yes" or "no" radio button. If "no" is selected, I want a form to popup. ...
5
votes
1answer
6k views

Remove an event listener after firing once or any number of times

Remove an event listener after firing once or any number of times This is what I have: ...
3
votes
1answer
2k views

Keeping UI responsive while performing long running task

I recently asked for some advice on the best way to structure my code for a program I was writing. (see this question on Programmers.SE). The solution I was given was quite elegant, however I am less ...
5
votes
1answer
150 views

Altering contents when loading iframes

I am quite new to JavaScript and I wonder if you experts can see any obvious mistakes in this working code, and if any, suggest good improvements. ...
5
votes
3answers
209 views
4
votes
2answers
885 views

Click handlers for SVG polygons

How can I write this shorter? ...
7
votes
1answer
2k views

Even handler for text input preview

In a WPF application I have the following event handler for PreviewTextInput event in ComboBox control. The main purpose of this ...
18
votes
2answers
29k views

Generic EventArgs to go with generic EventHandler?

There is as of .NET 2.0 a generic EventHandler delegate type, which can be used to define an event in terms of the EventArgs ...
3
votes
2answers
3k views

Mouseover effect for radio buttons

I'm very much a beginner and have put together some JavaScript to control a pair of radio buttons which essentially behave as links. I'm doing this as sort of a self-initiated project, or bit of fun. ...
1
vote
2answers
2k views

DataTables search filter handler

I am writing a JavaScript feature where by I need to make a call to a third-party library (pre-1.10 DataTables) depending upon whether or not the user provides an integer as an input to the function ...
5
votes
2answers
376 views

Window-scrolling controller

I generally feel that the pattern I use for development is kind of wrong. I start with simple functionality, then when I realize that some pieces can be reused I usually start to write "scope root ...
5
votes
3answers
484 views

Similar event handlers for buttons

I have 3 simple similar event handler functions that I would like to refactor. Any suggestions? ...
13
votes
2answers
822 views

Setting up radio button click ActionListeners

Instead of writing four almost identical setOnClickListener method calls, I opted to iterate over an array, but I'm wondering if this was the best way to do it. Do ...

1
5 6 7 8
9