How Do I Create A Dropdown Designer Property?

Hello developers
I am developing an extension. I wanted to add dropdown designer property and red block.
I created enum OptionList. So I could create red helper block. But I couldn't create dropdown designer property without editorArgs . Do I have to add editorArgs additionally.
My Property Method:

@DesignerProperty(defaultValue = "", editorType = PropertyTypeConstants.PROPERTY_TYPE_CHOICES)
@SimpleProperty(category = PropertyCategory.BEHAVIOR, description = "sets animation")
public void Animation(@Options(Animation.class) String anim) {
    this.animation = anim;
}

Se this thread for an example

Taifun

It does not have any designer property.

Here is another example taken from my alarmmanager extension App Inventor Extensions: Alarm Manager | Pura Vida Apps

/**
   * StartMode
   */
  @SimpleProperty(category = PropertyCategory.BEHAVIOR, description = "StartMode for alarm time. " +
          "Possible values are: 1, 2, 3 or 4. (1 = Only notification, 2 = Start Above Lock Screen or Notification, " +
          "3 = Start Always, 4 = Only Background Processing).")
  public String StartMode() {
    return startMode;
  }

  @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_STRING, defaultValue = "2")
  @SimpleProperty
  public void StartMode(@Options(StartMode.class) String startMode) {
    if ((startMode.equals("1")) || (startMode.equals("2")) || (startMode.equals("3")) || (startMode.equals("4"))) {
      this.startMode = startMode;
    } else {
      this.startMode = "2";
    }
  }

Taifun

If you want to do a dropdown in the designer side, you need to do the following:

@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_CHOICES,
    editorArgs = {"Option A", "Option B", "Option C"})
@SimpleProperty
public void MyProperty(String arg) { /* ... */ }

I don't believe there is a means currently of synchronizing the options between the two, but it could probably be done with a patch to App Inventor to auto populate the editorArgs field from the enum entries.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.