Processing MVC event handling

Hi, maybe I'm just missing the OOP way of event handling, for I am starting to use this event oriented programming, but as long as I get, processing.event seems to have a way for implementing this using an object Event.

So, what I understood of OOP events is that you declare a class that inherits the characteristics of the Event class, and the listener implements EventListener for java native libraries so it can have a special method, a listener, that receives an object of the Event child class. As far as I think I know, when an Event object is created, the "listener" class calls the listener method and executes the code.

For example:

<>SENDING CLASS<>

import processing.event.Event;

public class ModelProcessing { public void load() { new ModelEvent(); //The event is created and sent I guess } }

class ModelEvent extends Event { ModelEvent() { super(this,300,1,4); } }

<>RECEIVER CLASS<>

import java.util.EventListener;

public class ViewProcessing implements EventListener { public void ViewListener(ModelEvent event) { print("SENT"); } }

I am using Processing on Eclipse, I fear I am mixing Java and Processing mechanics, or I am not using the addListener() somewhere. Thanks for your time.

Answers

  • I fear I am mixing Java and Processing mechanics

    Yes that is true and it is very difficult to use both at the same time.

    It might we worth explaining what you hope to achieve, rather than how you hope to code it.

Sign In or Register to comment.