ReadOnlyTextArea.qml 848 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 1.1
  5. Item
  6. {
  7. id: base
  8. property alias text: textArea.text
  9. property alias wrapMode: textArea.wrapMode
  10. signal editingFinished();
  11. property bool readOnly: false
  12. width: textArea.width
  13. height: textArea.height
  14. TextArea
  15. {
  16. id: textArea
  17. enabled: !base.readOnly
  18. opacity: base.readOnly ? 0.5 : 1.0
  19. anchors.fill: parent
  20. Keys.onReturnPressed:
  21. {
  22. base.editingFinished()
  23. }
  24. Keys.onEnterPressed:
  25. {
  26. base.editingFinished()
  27. }
  28. onActiveFocusChanged:
  29. {
  30. if(!activeFocus)
  31. {
  32. base.editingFinished()
  33. }
  34. }
  35. }
  36. }