Hide action when widget is disabled

ChangeLog: TextEdit/LineEdit : disable context menu action when the widget is disabled or read-only
ChangeLog: Added ContextMenuArea::enabled
This commit is contained in:
Montel Laurent 2025-05-02 13:20:46 +02:00 committed by GitHub
parent bc5a468513
commit 4cd6f92013
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 53 additions and 15 deletions

View file

@ -68,10 +68,11 @@ export component LineEditBase inherits Rectangle {
}
ContextMenuArea {
enabled: root.enabled;
Menu {
MenuItem {
title: @tr("Cut");
enabled: root.enabled;
enabled: !root.read-only && root.enabled;
activated => {
text-input.cut();
}
@ -79,6 +80,7 @@ export component LineEditBase inherits Rectangle {
MenuItem {
title: @tr("Copy");
enabled: !root.text.is-empty;
activated => {
text-input.copy();
}
@ -86,7 +88,7 @@ export component LineEditBase inherits Rectangle {
MenuItem {
title: @tr("Paste");
enabled: root.enabled;
enabled: !root.read-only && root.enabled;
activated => {
text-input.paste();
}
@ -94,6 +96,7 @@ export component LineEditBase inherits Rectangle {
MenuItem {
title: @tr("Select All");
enabled: !root.text.is-empty;
activated => {
text-input.select-all();
}

View file

@ -59,10 +59,11 @@ export component TextEditBase inherits Rectangle {
forward-focus: text-input;
ContextMenuArea {
enabled: root.enabled;
Menu {
MenuItem {
title: @tr("Cut");
enabled: root.enabled;
enabled: !root.read-only && root.enabled;
activated => {
text-input.cut();
}
@ -70,14 +71,15 @@ export component TextEditBase inherits Rectangle {
MenuItem {
title: @tr("Copy");
enabled: !root.text.is-empty;
activated => {
text-input.copy();
}
}
MenuItem {
enabled: !root.read-only && root.enabled;
title: @tr("Paste");
enabled: root.enabled;
activated => {
text-input.paste();
}
@ -85,6 +87,7 @@ export component TextEditBase inherits Rectangle {
MenuItem {
title: @tr("Select All");
enabled: !root.text.is-empty;
activated => {
text-input.select-all();
}