[glass] NTStringChooser: Properly set retained (#6144)

This commit is contained in:
Peter Johnson
2024-01-03 09:38:10 -08:00
committed by GitHub
parent 25636b712f
commit 73c7d87db7
2 changed files with 9 additions and 7 deletions

View File

@@ -5,6 +5,7 @@
#include "glass/networktables/NTStringChooser.h"
#include <fmt/format.h>
#include <wpi/json.h>
using namespace glass;
@@ -16,17 +17,17 @@ NTStringChooserModel::NTStringChooserModel(nt::NetworkTableInstance inst,
: m_inst{inst},
m_default{
m_inst.GetStringTopic(fmt::format("{}/default", path)).Subscribe("")},
m_selected{
m_inst.GetStringTopic(fmt::format("{}/selected", path)).GetEntry("")},
m_selected{m_inst.GetStringTopic(fmt::format("{}/selected", path))
.Subscribe("")},
m_selectedPub{m_inst.GetStringTopic(fmt::format("{}/selected", path))
.PublishEx("string", {{"retained", true}})},
m_active{
m_inst.GetStringTopic(fmt::format("{}/active", path)).Subscribe("")},
m_options{m_inst.GetStringArrayTopic(fmt::format("{}/options", path))
.Subscribe({})} {
m_selected.GetTopic().SetRetained(true);
}
.Subscribe({})} {}
void NTStringChooserModel::SetSelected(std::string_view val) {
m_selected.Set(val);
m_selectedPub.Set(val);
}
void NTStringChooserModel::Update() {