Skip to content

Instantly share code, notes, and snippets.

@dtoebe
Created January 3, 2017 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtoebe/aedba350be339ce48d6fb31345699842 to your computer and use it in GitHub Desktop.
Save dtoebe/aedba350be339ce48d6fb31345699842 to your computer and use it in GitHub Desktop.
WRITE A SIMPLE MARKDOWN EDITOR WITH GO-QML - main.qml - 4
//assets/main.qml
...
TextArea {
id: rtarea
...
onActiveFocusChange: { //Signal if you leave or enter the focus of rtarea
if(!activeFocus) { //if you are not in the TextArea
rtarea.textFormat = TextEdit.RichText //change the rtarea.textFormat to show the RichText, default
} else { //if you are focused on the rtarea
rtarea.textFormat = TextEdit.PlainText //switch the textFormat to PlainText
htmlText.setHTMLText(mdarea.text) //now we grab the mdarea.text and parse the markdown
rtarea.text = htmlText.text //and set the newly parsed text to the rtarea.text
}
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment