Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [eventhandler]

In object-oriented programming languages (such as C++, Lazarus Pascal or Visual Basic), visual objects (or components) can respond to *events* (usually) by the user. An event handler is the block of code that runs when an event occurs. Eg: *Onclick* event for a command button.

eventhandler
-1 votes
2 answers
122 views

How to write Java Script arrow functions in regular function syntax?

I need help to rewrite some arrow functions to regular functions but right now my brain is totally stucked, I have some example code here from a rock paper scissors game I got from kyle, how would it ...
Peterman's user avatar
0 votes
1 answer
588 views

Task.Run invoking an EventHandler. Is it correct?

I am writing unit tests for an async method and I think I should avoid .Invoke inside Task.Run in the next function. Here is the current code under test: public class Foo { public event EventHandler&...
Alberto Martín's user avatar
1 vote
1 answer
249 views

Why don't we create an Event Handler delegate for binding a handler with an event when programmatically creating an event handler?

I am creating a Windows Form application in Visual Studio using C#. I am having trouble understanding the concept of Event Handler Delegates. If I create an event handler for an event using the ...
Aiman Fayyaz's user avatar
-1 votes
1 answer
407 views

How do I change the text of a System.Windows.Forms.Label from a public static void button_click event?

More details: Assume I am creating a form and a button and a label in the main function, and I want the label text to change when I click on the button. I am getting an error that the label is outside ...
user20255552's user avatar
3 votes
2 answers
3k views

How do I set the correct type for a click handler when using Svelte with TypeScript?

I am using Svelte with TypeScript. I have a button: <button on:click|preventDefault={clickHandler}> Click me </button> I am trying to set the correct type for the click handler. export ...
mikemaccana's user avatar
0 votes
0 answers
175 views

Assigning event handler with arguments to events using arrow functions

In the below snippet,during a click event, the arrow function gets called. Now, this arrow function in turn runs the code in its body. Now since callme() is a single line statement, so it should ...
zangetsu's user avatar
0 votes
1 answer
63 views

Mocking Event handling will not cover delegate function assigned

Trying to mock an EventHandler for an Event raised from another class. However, when I run the test, the test does not cover the code that implemented inside the handler. Test [Fact] public void ...
Stefan23's user avatar
4 votes
0 answers
1k views

How to Solve Event Hander Nullable Warning Problem

button1.Click += new System.EventHandler(button1_Click); For this code above the VS gives warning of CS8622 for "button1_Click" in the EventHandler: https://learn.microsoft.com/en-us/dotnet/...
Programmable Physics's user avatar
-1 votes
5 answers
358 views

How to differentiate between buttons using the same class using a function?

I have this simple page set up which will add or remove a hidden class on an element when either button is clicked. The code works fine as is, but I know that it's very inefficient. I plan on adding ...
Taylor Remund's user avatar
0 votes
1 answer
722 views

Event.target types for name input in FromHandler with TypeScript

I have a simple form in a React SPA with typescript. I'm going to make this form processing simple, without adding component state and so, just to get value from the named input, name = 'gameId'. ...
Roman Poludnev's user avatar
1 vote
3 answers
96 views

adding an eventhandler to datagridview

I am trying to add a key event handler to a Datagridview. I have added this (below) to my code:L private void DgvDb_KeyUp(object sender, KeyEventArgs e) { colI = DgvDb.CurrentCell.ColumnIndex; ...
jjob's user avatar
  • 11
0 votes
1 answer
624 views

Javascript event listener structure

I’m working on a code to get the index of a clicked element so it can add or remove a class to display or hide the information. For it I used for for iteration. But I don’t understand why is there an (...
Antutu's user avatar
  • 5
1 vote
0 answers
73 views

Does a bodiless function in JavaScript prevent the default of an event?

I set the "passive" Parameter of a touchmove event to true and therefore can't call e.preventDefault() inside the function. But I need the function to prevent the default behaviour of the ...
MMF's user avatar
  • 33
0 votes
2 answers
1k views

Updating state twice when the button is clicked, React

I want to create simple 2048 game application. My initial board is composed of 16 array elements. The generate() function generates a value of '2' in a random empty element It works just fine and ...
Skydround's user avatar
0 votes
0 answers
17 views

How can I stop the app from stopping every time I click on a button to leave the current slideshow to a new activity

I have a simple slideshow with 20 slides and a 5 sec. time delays using the handler class, and the media player class that plays a different sound on each slide. There is a button on this activity ...
Ramon Akoto's user avatar

15 30 50 per page
1 2 3
4
5
55