Is Processing a good example of 'event driven programming'?

edited February 2017 in General Discussion

Hi - I'm new to processing and this forum. Please could somebody confirm (or otherwise) that processing is a good example of event driven programming. I need to teach this concept to some FE students and would like to introduce them to Processing at some stage - Could this be an ideal time???? Many Thanks.

Answers

  • Partially yes. I think most modern languages when dealing w/ user input goes w/ the event-driven approach.

  • Processing is based on Java which readily supports event driven programming.

    So Processing would be a good choice especially is the students are new to programming because it hides some of the complexities of the Java language.

  • edited February 2017

    Yeah, mousePressed ()

    mouseReleased()

    mouseClicked()

    mouseWheel ()

    keyPressed() etc etc ....

  • edited February 2017

    @chrisnewth -- following @Chrisir --

    The Processing UI paradigm is event-driven, and many of its UI demo sketches are good examples of this. I would recommend looking through the reference page under the sections Input > Mouse and Input > Keyboard:

    For example:

    The mouseClicked() function is called after a mouse button has been pressed and then released.

    Mouse and keyboard events only work when a program has draw(). Without draw(), the code is only run once and then stops listening for events.

    This introduces the basics:

    1. in Processing you define standard functions (such as mouseClicked()) to handle events
    2. the system listens for events and then calls those functions
    3. in event-driven programming listening and calling process that "drives" events is generally dependent on a "main loop" -- in the case of Processing, this loop is draw()
Sign In or Register to comment.