1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

ChoicePropertyComponent: Allow slightly more relaxed matching in getValue

This commit is contained in:
reuk 2021-08-09 17:42:31 +01:00
parent ff24f4acd3
commit 3c1393ecb6

View file

@ -82,14 +82,18 @@ public:
var getValue() const override
{
if (valueWithDefault != nullptr
&& ! valueWithDefault->isUsingDefault())
if (valueWithDefault != nullptr && ! valueWithDefault->isUsingDefault())
{
auto targetValue = sourceValue.getValue();
const auto target = sourceValue.getValue();
const auto equalsWithSameType = [&target] (const var& map) { return map.equalsWithSameType (target); };
for (auto map : mappings)
if (map.equalsWithSameType (targetValue))
return mappings.indexOf (map) + 1;
auto iter = std::find_if (mappings.begin(), mappings.end(), equalsWithSameType);
if (iter == mappings.end())
iter = std::find (mappings.begin(), mappings.end(), target);
if (iter != mappings.end())
return 1 + (int) std::distance (mappings.begin(), iter);
}
return -1;