| 2275 | } |
| 2276 | |
| 2277 | bool RmlImModeLayout::prop_enum(nb::object data, const std::string& prop_id, |
| 2278 | const std::string& value, const std::string& text) { |
| 2279 | const std::string current = nb::cast<std::string>(data.attr(prop_id.c_str())); |
| 2280 | const bool selected = (current == value); |
| 2281 | const std::string& display = text.empty() ? value : text; |
| 2282 | |
| 2283 | bool clicked; |
| 2284 | if (selected) |
| 2285 | clicked = button_styled(display, "primary"); |
| 2286 | else |
| 2287 | clicked = button(display); |
| 2288 | |
| 2289 | if (clicked && !selected) { |
| 2290 | data.attr(prop_id.c_str()) = nb::cast(value); |
| 2291 | return true; |
| 2292 | } |
| 2293 | return false; |
| 2294 | } |
| 2295 | |
| 2296 | nb::object RmlImModeLayout::operator_(const std::string& operator_id, const std::string& text, |
| 2297 | const std::string& /*icon*/) { |