what is an event?

  • Thread starter Thread starter e-mid
  • Start date Start date
E

e-mid

i used mouseEvents or clickEvents etc.. but i did not still understand what
an event is yet.

eg: when we press a button, the eventhandler registered with the the
button's click *event* is invoked. what is "button's click event" here?
or can we write this event from scratch?

eg: we have an integer , say i. incrementing the i , i++ . could this be an
event too?
i mean, can we invoke a function (or a eventhandler), when i is incremented?
 
e-mid said:
i used mouseEvents or clickEvents etc.. but i did not still understand what
an event is yet.

eg: when we press a button, the eventhandler registered with the the
button's click *event* is invoked. what is "button's click event" here?
or can we write this event from scratch?

An event is basically a delegate which is exposed to the outside world
in such a way that other classes can only add delegates to it and
remove them. At some point or other, the class which contains the event
can then fire/raise it by executing the delegates which have subscribed
to it.
eg: we have an integer , say i. incrementing the i , i++ . could this be an
event too?
No.

i mean, can we invoke a function (or a eventhandler), when i is incremented?

No.
 
i mean, can we invoke a function (or a eventhandler), when i is
incremented?
Well you could, if 'i' was a property, and on the set code you can invoke an
event to say it's been modified.
 
e-mid,

To put it in layman terms,

event is the place where you get control in your code, based on user's
action.

The common user actions are,

1. moving or clicking mouse
2. playing with keyboard

If you want to do something as soon as the user completed the above
operation, event is the best place to put ur code becoz you can get control
immediately and will know some basic parameters. For example, during
keyboard events, you will get some useful information like, which "key" has
been pressed.

Shak.
 
Back
Top