How to remove a previously drawn ControlP5 dropdown list in Processing

1.7k Views Asked by At

I've written a sketch in Processing that creates 3 nodes on which a user can click to display a dropdown list. Is there a way to make the dropdown list disappear on, say, an outside mouseclick or a release of the mouse button? I figured I could just call the background in the Draw section and it would overwrite the lists, but that appears not to be the case because they're not actually parts of the drawing. Thank you!

1

There are 1 best solutions below

1
On BEST ANSWER

It is always good to look at the documentation (included with the library).

From the ConrolP5 developer's site

Show, hide, load, save Controllers that have been added to your sketch can be arranged in tabs and groups to keep your controller sets organized. All controllers are drawn on top of a processing sketch by default. Several key combinations allow you to show and hide the user interface, and to saved and loaded ControlP5 properties, ControlP5properties → example. The position of a controller can be adjusted during runtime by moving a controller while the ALT-key is pressed.

Class DropdownListinherits from Class ControllerGroup which has a method: hide

 hide

public java.lang.Object hide()

    Specified by:
        hide in interface ControllerInterface

So to accomplish what you want, you need to track the mouseClick and then target the specific item you want to hide.