ReadOnlyTextArea.qml 928 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Controls 2.15
  5. import UM 1.5 as UM
  6. ScrollView
  7. {
  8. id: base
  9. property alias text: textArea.text
  10. property alias wrapMode: textArea.wrapMode
  11. signal editingFinished();
  12. property bool readOnly: false
  13. TextArea
  14. {
  15. id: textArea
  16. enabled: !base.readOnly
  17. selectByMouse: true
  18. background: UM.UnderlineBackground { id: backgroundRectangle }
  19. color: UM.Theme.getColor("text")
  20. selectionColor: UM.Theme.getColor("text_selection")
  21. font: UM.Theme.getFont("default")
  22. Keys.onReturnPressed: base.editingFinished()
  23. Keys.onEnterPressed: base.editingFinished()
  24. onActiveFocusChanged:
  25. {
  26. if(!activeFocus)
  27. {
  28. base.editingFinished()
  29. }
  30. }
  31. }
  32. }