mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[glass] NTStringChooser: Properly set retained (#6144)
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user