Skip to content

withPosition not working correctly inside a ShuffleboardLayout of type BuiltInLayouts.kList #4127

Open
@smoser

Description

@smoser

Describe the bug
withPosition is being honored inside a ShuffleboardLayout of type kList.

To Reproduce
Steps to reproduce the behavior:

  1. create a new project and put the following into src/main/java/frc/robot/Robot.java
package frc.robot;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;

public class Robot extends TimedRobot {
  private ShuffleboardTab shuffTab = Shuffleboard.getTab("MyTab");

  public void addTab(String name) {
    ShuffleboardLayout myGroup = shuffTab.
        getLayout(name, BuiltInLayouts.kList).withSize(1, 3);
    myGroup.add("Enable", true).withWidget(BuiltInWidgets.kToggleSwitch).
        withPosition(0, 0).getEntry();
    myGroup.add("Invert", false).withWidget(BuiltInWidgets.kToggleSwitch).
        withPosition(0, 1).getEntry();
    myGroup.add("Rotations", 0).withPosition(0, 2).getEntry();
    myGroup.add("Target", 1).withPosition(0, 3).getEntry();
  }

  @Override
  public void robotInit() {
    addTab("group 1");
    addTab("group 2");
    addTab("group 3");
  }

  @Override
  public void autonomousPeriodic() {  }

  @Override
  public void teleopPeriodic() {  }
}
  1. Run project
  2. Open shuffleboard

Expected behavior
I expected each "group" to have the indicated order of widgets.
What happens is that the groups differ seemingly randomly.
I expected that widgets order inside would be 'Enable', 'Invert', 'Rotations', 'Target' based on the use of withPosition.

Note that this does work with kGrid.

Screenshots
screenshot

Desktop (please complete the following information):

  • WPILib Version:2022.3.1
  • OS: Linux
  • Java version: from wpilib: openjdk version "11.0.13" 2021-10-19
  • C++ version: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions