Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to prevent using key sequences in TextArea

How to prevent using key sequences in TextArea

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 279 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlexChris
    wrote on last edited by
    #1

    Hello, everyone! Now, I'd like to prevent users from using Ctrl+Z in TextArea and I'm doing like this:
    TextArea{
    Keys.onPressed: {
    if(event.matches(StandardKey.Undo)){
    event.accepted = false
    console.log("prevent undo:")
    }
    }
    }
    Although I've received "prevent undo" in the console, the key sequences still works. Does anyone know the answer ? Thanks in advance.

    jsulmJ 1 Reply Last reply
    0
    • A AlexChris

      Hello, everyone! Now, I'd like to prevent users from using Ctrl+Z in TextArea and I'm doing like this:
      TextArea{
      Keys.onPressed: {
      if(event.matches(StandardKey.Undo)){
      event.accepted = false
      console.log("prevent undo:")
      }
      }
      }
      Although I've received "prevent undo" in the console, the key sequences still works. Does anyone know the answer ? Thanks in advance.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @AlexChris said in How to prevent using key sequences in TextArea:

      event.accepted = false

      Shouldn't you set it to true to signal that you want to process it on your own without propagating it further?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved