# Object help new user

**URL:** <https://discourse.processing.org/t/object-help-new-user/24711>\
**Category:** Libraries\
**Created:** [October 19, 2020, 2:42pm UTC](https://discourse.processing.org/t/object-help-new-user/24711 "2020-10-19T14:42:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike\_z](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mike\_z](https://discourse.processing.org/u/mike_z)\
**Post date:** [October 19, 2020, 2:42pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/1 "2020-10-19T14:42:37Z")

</div>

I’m a realtively new user. I’ve been watching Dan SHiffman videos and studying the examples given in the processing environment. Lately, I’ve been studying the example in the contributed libraries/controlP5/controllers/controlP5Button. In this example there is a function  
\<  
public void controlEvent(ControlEvent theEvent) {  
println(theEvent.getController().getName());  
n = 0;  
}

The argument seems to be an Object(?). But I can not find it in the code. After nosing around a little it seems it is part of the controlP5 library and it is a Java Object. Is this correct? How can I better understand what the function shown above works? Thanks Mike  
/\>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 20, 2020, 10:24pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/2 "2020-10-20T22:24:43Z")

</div>

please read the docu of controlP5

the function above is called automatically when a button is clicked for example and allows you to evaluate the button or whatever.

see [https://github.com/sojamo/controlp5/blob/master/examples/controllers/ControlP5button/ControlP5button.pde](https://github.com/sojamo/controlp5/blob/master/examples/controllers/ControlP5button/ControlP5button.pde)

---

<div class="post-metadata">

**Author:** ![mike\_z](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mike\_z](https://discourse.processing.org/u/mike_z)\
**Post date:** [October 20, 2020, 11:13pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/3 "2020-10-20T23:13:53Z")

</div>

WHere do I find the document controlP5? This is exactly what I’m looking for. I would like to have the opportunity to read about things, rather than guess. Mike

---

<div class="post-metadata">

**Author:** ![mike\_z](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mike\_z](https://discourse.processing.org/u/mike_z)\
**Post date:** [October 20, 2020, 11:40pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/4 "2020-10-20T23:40:54Z")

</div>

I found a document on GitHub. Is this the document you are refering to? I intend to study this and hopefully it will help me out, thanks, Mike

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 21, 2020, 9:31am UTC](https://discourse.processing.org/t/object-help-new-user/24711/5 "2020-10-21T09:31:07Z")

</div>

I have to admit the documentation is not very good.

see [http://www.sojamo.de/libraries/controlP5/#resources](http://www.sojamo.de/libraries/controlP5/#resources)

There are also examples directly in the processing IDE:

- Menu File | Examples | Contributed Libraries | ControlP5

Chrisir

---

<div class="post-metadata">

**Author:** ![mike\_z](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mike\_z](https://discourse.processing.org/u/mike_z)\
**Post date:** [October 21, 2020, 2:48pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/6 "2020-10-21T14:48:15Z")

</div>

Thanks for the reply. Holy Cow there is a large gap between the beginner YouTube videos and these examples. This is where I’m having trouble finding information regarding these items that are beyond the beginner stuff. I started to look over the cp5 radio button example. There is a lot of short cut items here that I can guess at, but what really has me stumped right now is the object method with two dot syntax.  
for example;  
\<theEvent.getGroup().getValue()/\>  
I don’t want to ask questions for every item like this a comes up. I would like to see a good reference book with how this stuff works. Thanks Mike

---

<div class="post-metadata">

**Author:** ![mike\_z](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mike\_z](https://discourse.processing.org/u/mike_z)\
**Post date:** [October 21, 2020, 6:16pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/7 "2020-10-21T18:16:29Z")

</div>

Well I’m trying to understand how this code works, by guessing. Looking at the control P5 radiobutton example. It has some code;  
\< cp5 = new ControlP5(this);  
r1 = cp5.addRadioButton(“radioButton”)  
.setPosition(100,180)  
.setSize(40,20)  
.setColorForeground(color(120))  
.setColorActive(color(255))  
.setColorLabel(color(255))  
.setItemsPerRow(5)  
.setSpacingColumn(50)  
.addItem(“50”,1)  
.addItem(“100”,2)  
.addItem(“150”,3)  
.addItem(“200”,4)  
.addItem(“250”,5)  
;  
/\>  
First what is “this” key word really do? Could I replace it with r1 in this simply example?  
Then the rest seems to be a run on statement. There are no ; after each line and just one ; at the end. Is this some kind of short hand? How would you write it out in a long more visual descriptive way? I tried adding ;'s and cp5 prior to the dot’s and r1 = cp5 prior to the dot, but errors occur. Confused, Mike

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 21, 2020, 8:30pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/8 "2020-10-21T20:30:13Z")

</div>

> [@mike\_z](#):
>
> theEvent.getGroup().getValue()

here, the event is the radio button.  
It consists of 5 items (the group).

so this: theEvent.getGroup() gives you the object group.

Then we get the value from the group (pressed item)

so this can be written in a row (`theEvent.getGroup().getValue()`), or you can tear it apart:

```auto
    println("\t "+theEvent.getValue());
    ControlGroup gr=theEvent.getGroup(); // step 1 
    myColorBackground = color(int(gr.getValue()*50), 0, 0); // step 2

```

* * *

> [@mike\_z](#):
>
> I’m having trouble finding information regarding these items that are beyond the beginner stuff

Yeah, did you check the JavaDoc?

[http://www.sojamo.de/libraries/controlP5/reference/index.html](http://www.sojamo.de/libraries/controlP5/reference/index.html)

> [@mike\_z](#):
>
> First what is “this” key word really do?

It’s a reference to your Sketch and hands a pointer to the Sketch. It’s a technical thing, dunno.

> [@mike\_z](#):
>
> Could I replace it with r1 in this simply example?

No.

> [@mike\_z](#):
>
> Then the rest seems to be a run on statement.

Yes.

> [@mike\_z](#):
>
> Is this some kind of short hand?

Yes.

> [@mike\_z](#):
>
> How would you write it out in a long more visual descriptive way?

all with the dot are referring to cp5.addRadioButton(“radioButton”)…

so a long form is to use r, the object we are referring to.

```auto

  // *********************************
  r = cp5.addRadioButton("radioButton");
  // *********************************

  r.setPosition(20, 160);
  r.setSize(40, 20);
  r.setColorForeground(color(120));
  r.setColorActive(color(255));
  r.setColorLabel(color(255));
  r.setItemsPerRow(5);
  r.setSpacingColumn(50);
  r.addItem("50", 1);
  r.addItem("100", 2);
  r.addItem("150", 3);
  r.addItem("200", 4);
  r.addItem("250", 5);

```

So when we init the radio button, we pass a lot of values / properties to it.

Chrisir

---

<div class="post-metadata">

**Author:** ![mike\_z](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mike\_z](https://discourse.processing.org/u/mike_z)\
**Post date:** [October 21, 2020, 9:18pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/9 "2020-10-21T21:18:28Z")

</div>

Thanks for the reply, I really appreciate your help. I’ve been reading about ‘this’. Apparently, it passes the current object, which I thought was r1 in the example, to the constructor of the class.Just to be clear, is the controlP5 the class and the .addRadioButton(), for example are functions within that class?  
I tried the long notation and found that it still works. I think that I will use the long hand until I really understand what I’m doing.  
The last question is in regard to the double dot stuff, for example,  
\<theEvent.getGroup().getValue()/\>  
Does this mean that within the function ‘theEvent’ there is another function ‘getGroup()’ and in that function another function getValue()?  
Again I appreciate your help. Mike

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 21, 2020, 9:32pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/10 "2020-10-21T21:32:48Z")

</div>

> [@mike\_z](#):
>
> Does this mean that within the function ‘theEvent’ there is another function ‘getGroup()’…

- A correction: _theEvent_ isn’t a function but a function (aka method in Java) parameter.
- A parameter is initialized by the argument passed to it when invoking its function.
- That parameter _theEvent_ is declared as datatype ControlEvent.
- It means we can access any `public` member of that type using the operator `.` dot.
- Inside that **controlEvent()** callback function we can see the method **getGroup()** is invoked over its parameter _theEvent_.
- And after that another method named **getName()** is chain-invoked over the object returned by the method **getGroup()**.
- In order to know which datatype belongs the object returned by method **getGroup()** we need to read the docs about datatype ControlEvent though.

---

<div class="post-metadata">

**Author:** ![mike\_z](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mike\_z](https://discourse.processing.org/u/mike_z)\
**Post date:** [October 21, 2020, 9:44pm UTC](https://discourse.processing.org/t/object-help-new-user/24711/11 "2020-10-21T21:44:35Z")

</div>

Thanks, I think I need some time to digest all this, but good stuff. Mike
