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

Method onAction

src/app/MenuBar.cpp:135–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133
134struct EditButton : MenuButton {
135 void onAction(const ActionEvent& e) override {
136 ui::Menu* menu = createMenu();
137 menu->cornerFlags = BND_CORNER_TOP;
138 menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
139
140 struct UndoItem : ui::MenuItem {
141 void step() override {
142 bool canUndo = APP->history->canUndo();
143 text = canUndo ? string::f(string::translate("MenuBar.edit.undoAction"), APP->history->getUndoName()) : string::translate("MenuBar.edit.undo");
144 disabled = !canUndo;
145 MenuItem::step();
146 }
147 void onAction(const ActionEvent& e) override {
148 APP->history->undo();
149 }
150 };
151 menu->addChild(createMenuItem<UndoItem>("", widget::getKeyCommandName(GLFW_KEY_Z, RACK_MOD_CTRL)));
152
153 struct RedoItem : ui::MenuItem {
154 void step() override {
155 bool canRedo = APP->history->canRedo();
156 text = canRedo ? string::f(string::translate("MenuBar.edit.redoAction"), APP->history->getRedoName()) : string::translate("MenuBar.edit.redo");
157 disabled = !canRedo;
158 MenuItem::step();
159 }
160 void onAction(const ActionEvent& e) override {
161 APP->history->redo();
162 }
163 };
164 menu->addChild(createMenuItem<RedoItem>("", widget::getKeyCommandName(GLFW_KEY_Z, RACK_MOD_CTRL | GLFW_MOD_SHIFT)));
165
166 menu->addChild(createMenuItem(string::translate("MenuBar.edit.clearCables"), "", [=]() {
167 APP->patch->disconnectDialog();
168 }));
169
170 menu->addChild(new ui::MenuSeparator);
171
172 APP->scene->rack->appendSelectionContextMenu(menu);
173 }
174};
175
176

Callers

nothing calls this directly

Calls 8

createMenuFunction · 0.85
VecClass · 0.85
getKeyCommandNameFunction · 0.85
createMenuItemFunction · 0.85
translateFunction · 0.85
addChildMethod · 0.80
disconnectDialogMethod · 0.80

Tested by

no test coverage detected