WelderEngineRevamp icon indicating copy to clipboard operation
WelderEngineRevamp copied to clipboard

Ctrl+C does not copy objects selected in Objects view

Open jayrulez opened this issue 1 year ago • 0 comments

    if (shell->IsKeyDown(Keys::Control) && (key == Keys::C || key == Keys::X) && shell->mOnCopy)
    {
      ClipboardData data;
      shell->mOnCopy(data, key == Keys::X, shell);
      ErrorIf(!data.mHasText && !data.mText.Empty(), "Clipboard Text was not empty, but HasText was not set");
      if (data.mHasText)
        WindowsSetClipboardText(data.mText.c_str());
      ErrorIf(data.mHasImage, "Copying image data not yet supported");
    }

The code above in Shell.cpp, specifically shell->mOnCopy(data, key == Keys::X, shell); will call into OsShell::ShellOnCopy. This will eventually reach RootWidget::OnCutCopyPaste(ClipboardEvent* event).

void RootWidget::OnCutCopyPaste(ClipboardEvent* event)
{
  if (Widget* focusObject = mFocus)
    focusObject->DispatchBubble(event->EventId, event);
}

It will try to dispatch the clipboard event on the focused object. This is where the problem lies. The focused object in most cases will be the text element selected in the Objects view (if you didn't move the mouse over another element that steals the focus). This element does not have the editor view port (which should handle the copy event) in its hierarchy, so the selected object(s) does not get copied as expected.

jayrulez avatar Oct 28 '23 15:10 jayrulez