MCPcopy Create free account
hub / github.com/VCVRack/Rack / createCheckMenuItem

Function createCheckMenuItem

include/helpers.hpp:254–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252*/
253template <class TMenuItem = ui::MenuItem>
254TMenuItem* createCheckMenuItem(std::string text, std::string rightText, std::function<bool()> checked, std::function<void()> action, bool disabled = false, bool alwaysConsume = false) {
255 struct Item : TMenuItem {
256 std::string rightTextPrefix;
257 std::function<bool()> checked;
258 std::function<void()> action;
259 bool alwaysConsume;
260
261 void step() override {
262 this->rightText = rightTextPrefix;
263 if (checked()) {
264 if (!rightTextPrefix.empty())
265 this->rightText += " ";
266 this->rightText += CHECKMARK_STRING;
267 }
268 TMenuItem::step();
269 }
270 void onAction(const event::Action& e) override {
271 action();
272 if (alwaysConsume)
273 e.consume(this);
274 }
275 };
276
277 Item* item = createMenuItem<Item>(text);
278 item->rightTextPrefix = rightText;
279 item->checked = checked;
280 item->action = action;
281 item->disabled = disabled;
282 item->alwaysConsume = alwaysConsume;
283 return item;
284}
285
286
287/** Creates a MenuItem that controls a boolean value with a check mark.

Callers 7

appendContextMenuMethod · 0.85
onActionMethod · 0.85
onActionMethod · 0.85
createChildMenuMethod · 0.85
onActionMethod · 0.85
appendLanguageMenuFunction · 0.85
createChildMenuMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected