Skip to content

Customize the display name of GUI's Controller #203

@hijiangtao

Description

@hijiangtao

According to the code

this.property = property;
, the name of the property to manipulate is set to the same as the display name of the controller.

However, there are many situations that developers want to differentiate the manipulated property with its display name, such as Chinese words, space, special characters, etc.

We can add a property to the base class - Controller (suppose the new property is named name), and decide whether to use it when we call the .add() method (we can use expression like name || property to set the inner HTML of this Controller),

name.innerHTML = controller.property;

This new property can be set in the second parameter property, too. So the second parameter can be an object or a string normally, it's perfectly compatible to previous version in this way, and the only thing that dat.gui need to handle is judge the type of property and decide whether to set the name in the instance.

I can raise a PR if this approach is acceptable for you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions