diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index f21e56c5d1..a0feef5dc7 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -4086,7 +4086,15 @@ bool wxRichTextCtrl::SetDefaultStyleToCursorStyle() // If at the start of a paragraph, use the next position. long pos = GetAdjustedCaretPosition(GetCaretPosition()); - if (GetUncombinedStyle(pos, attr)) + wxRichTextObject* obj = GetFocusObject()->GetLeafObjectAtPosition(pos); + if (obj && obj->IsTopLevel()) + { + // Don't use the attributes of a top-level object, since they might apply + // to content of the object, e.g. background colour. + SetDefaultStyle(wxRichTextAttr()); + return true; + } + else if (GetUncombinedStyle(pos, attr)) { SetDefaultStyle(attr); return true; diff --git a/src/richtext/richtextstyles.cpp b/src/richtext/richtextstyles.cpp index 8484ce683b..86e64ccfbb 100644 --- a/src/richtext/richtextstyles.cpp +++ b/src/richtext/richtextstyles.cpp @@ -442,7 +442,7 @@ bool wxRichTextStyleSheet::AddListStyle(wxRichTextListStyleDefinition* def) /// Add a definition to the box style list bool wxRichTextStyleSheet::AddBoxStyle(wxRichTextBoxStyleDefinition* def) { - def->GetStyle().SetParagraphStyleName(def->GetName()); + def->GetStyle().GetTextBoxAttr().SetBoxStyleName(def->GetName()); return AddStyle(m_boxStyleDefinitions, def); }