Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mousearea inside a textfield disabled textfield's functionality
Forum Updated to NodeBB v4.3 + New Features

Mousearea inside a textfield disabled textfield's functionality

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 454 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.
  • E Offline
    E Offline
    ehsanen
    wrote on last edited by
    #1

    Hi,
    I need a customised textfield that behaves normally when user clicks inside it, but if the user Alt+Clicks I want it to run some special codes instead of being able to edit the text. Here is a sample code:

    ApplicationWindow {
            visible: true
            width: 700
            height: 700
    
    TextField{
        id: mytextfield
        width: 500
        height: 40
    
        MouseArea {
            id: textboxMouseArea
            propagateComposedEvents: true
            anchors.fill: parent
            onClicked:
            {
                if(mouse.modifiers & Qt.AltModifier)
                {
                     console.log("Alt CLICKED")
                }
                mouse.accepted = false
            }
        }
      }
    }
    

    I set propagateComposedEvents and also set mouse.accepted = false but it still doesn't work. Alt+Click detection works fine, but textfield is somehow disabled and I cannot edit the text.
    Is there any ideas/workaround for this?

    Thanks

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AYYAPPA
      wrote on last edited by AYYAPPA
      #2

      ApplicationWindow {
      visible: true
      width: 700
      height: 700

          TextField
          {
              id: mytextfield
              width: 500
              height: 40
              Keys.onPressed: {
                  //mark event as handled, prevent it from passing on.
                  event.accepted = true;
                  if(mouse.modifiers & Qt.AltModifier)
                  {
                      console.log("Alt CLICKED")
                  }
              }
          }
      }
      
      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