Post: [C#] Basic use of Events
01-21-2015, 11:10 AM #1
Winter
Purple God
(adsbygoogle = window.adsbygoogle || []).push({});
Someone asked me to show them the basics to making your own Events. Thought I'd might as well post it on NGU incase other people are curious also.. Pretty much copied and pasted this out of my ShoutBox, but yeah. There is a lot of stuff you can do with this, so it's pretty useful-ish :P (as I said, BASIC)

You must login or register to view this content.
if you're wondering why I took a screenshot and put it here; I hate it when people don't put screenshots of their stuff.


You must login or register to view this content.
You must login or register to view this content.

The following 3 users say thank you to Winter for this useful post:

Boliberrys, xBxAxYxRxAxMx
01-21-2015, 05:13 PM #2
jagex
Gym leader
Hey,

I have a question.

I always set my event handlers like this
    rectangleLogIn.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
rectangleRegister.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;


Should I always be initializing a new event or is this way fine? Thanks!
01-21-2015, 05:29 PM #3
Originally posted by Winter View Post
Someone asked me to show them the basics to making your own Events. Thought I'd might as well post it on NGU incase other people are curious also.. Pretty much copied and pasted this out of my ShoutBox, but yeah. There is a lot of stuff you can do with this, so it's pretty useful-ish :P (as I said, BASIC)

You must login or register to view this content.
if you're wondering why I took a screenshot and put it here; I hate it when people don't put screenshots of their stuff.


You must login or register to view this content.
You must login or register to view this content.


Temp approves Needa You must login or register to view this content.
01-23-2015, 10:18 AM #4
Winter
Purple God
Originally posted by jagex View Post
Hey,

I have a question.

I always set my event handlers like this
    rectangleLogIn.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
rectangleRegister.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;


Should I always be initializing a new event or is this way fine? Thanks!


That's if you're constructing your own enums/if you're using someone elses premade stuff (like Microsoft) but what the person wanted to know is how to create your own. Since the enum pretty much has no return type it needs to be delegated. But as long as your way gets the job done it'll do fine, although you could pretty much just make a void.

-I thought I replied to this the other day, apparently NGU decided to fuck up, sorry, I restored auto saved content thank fuck lol

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo