Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2016-07-29 12:41:23, last edited by tinglyLiar41 (2016-07-29 12:41:59)

tinglyLiar41
Anonymous user

[Question] Triggering an event when integer is changed.

Well, as the title says.
How do trigger an event when a public integer is changed? I've searched the web but nothing helped me.

Thanks.

Wooted by:

#2 2016-07-29 13:00:08

MaggotyUlcer28
Anonymous user

Re: [Question] Triggering an event when integer is changed.

Seems you didn't look hard enough - http://stackoverflow.com/questions/5842 … is-changed

To summarise the answers there, in the most basic way possible, otherwise see the link above.

private int _MyFavouriteNumber
public int MyFavouriteNumber {
    get { return _MyFavouriteNumber }
    set {
        _MyFavouriteNumber = value;
        DoSomething();
    }
}

Wooted by:

#3 2016-07-29 13:12:34

macho muffin
Anonymous user

Re: [Question] Triggering an event when integer is changed.

My how we have fallen so that those who desire help also need the guise of anonymity…
But yeah, this is where get/set blocks make sense to me

Wooted by: (2)

#4 2016-07-29 13:16:28, last edited by tinglyLiar41 (2016-07-29 13:17:27)

tinglyLiar41
Anonymous user

Re: [Question] Triggering an event when integer is changed.

Does that works if it increases/decreases?

Hidden text

#5 2016-07-29 13:23:22

Schoolgirl60
Anonymous user

Re: [Question] Triggering an event when integer is changed.

tinglyLiar41 wrote:

I might post un-anonymously. Someday...

Any time the value is changed (this includes the example below) even if you did

MyFavouriteNumber = 1215;
MyFavouriteNumber = 1215;

The function will be fired twice

#6 2016-07-29 13:31:23

tinglyLiar41
Anonymous user

Re: [Question] Triggering an event when integer is changed.

Ah, thank you. I get confused when somepony sends a code without explenation.
Thread closed.

Board footer

Powered by FluxBB

[ Started around 1732417563.513 - Generated in 0.040 seconds, 12 queries executed - Memory usage: 1.41 MiB (Peak: 1.51 MiB) ]