[studio] Add acceptsClipboardPayload to Editor

This commit is contained in:
Gary Talent 2024-05-28 20:58:26 -05:00
parent 791d19504e
commit a138f60fea
4 changed files with 14 additions and 2 deletions

View File

@ -209,7 +209,7 @@ void StudioUI::drawMenu() noexcept {
if (ImGui::MenuItem("Cut", "Ctrl+X", false, m_activeEditor && m_activeEditor->cutEnabled())) {
m_activeEditor->cut();
}
if (ImGui::MenuItem("Paste", "Ctrl+V", false, m_activeEditor && m_activeEditor->pasteEnabled()) && m_activeEditor) {
if (ImGui::MenuItem("Paste", "Ctrl+V", false, m_activeEditor && m_activeEditor->pasteEnabled())) {
m_activeEditor->paste();
}
ImGui::EndMenu();

View File

@ -22,4 +22,9 @@ struct StudioContext {
ui(pUi), tctx(pTctx) {}
};
[[nodiscard]]
constexpr keel::Context &keelCtx(StudioContext &ctx) noexcept {
return keelCtx(ctx.tctx);
}
}

View File

@ -43,6 +43,9 @@ class BaseEditor: public Widget {
virtual void paste();
[[nodiscard]]
virtual bool acceptsClipboardPayload() const noexcept;
virtual void exportFile();
virtual void keyStateChanged(turbine::Key key, bool down);

View File

@ -23,6 +23,10 @@ void BaseEditor::copy() {
void BaseEditor::paste() {
}
bool BaseEditor::acceptsClipboardPayload() const noexcept {
return {};
}
void BaseEditor::exportFile() {
}
@ -95,7 +99,7 @@ void BaseEditor::setPasteEnabled(bool v) {
}
bool BaseEditor::pasteEnabled() const noexcept {
return m_pasteEnabled;
return m_pasteEnabled && acceptsClipboardPayload();
}
ox::Error BaseEditor::saveItem() noexcept {