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

@ -219,8 +219,11 @@ component ContextMenu inherits Empty {
callback activated(entry: MenuEntry);
callback sub-menu(entry: MenuEntry) -> [MenuEntry];
callback show(position: Point);
function close() {}
function is-open() -> bool {}
function close() {
}
function is-open() -> bool {
}
in property <bool> enabled: true;
}
// Lowered in lower_menus pass.
@ -236,11 +239,13 @@ export component ContextMenuInternal inherits ContextMenu {
export component ContextMenuArea inherits Empty {
// This is actually function as part of out interface, but a callback as much is the runtime concerned
callback show(position: Point);
function close() {}
function close() {
}
//-default_size_binding:expands_to_parent_geometry
Menu {}
}
Menu { }
in property <bool> enabled: true;
}
component WindowItem {
in-out property <length> width;

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();
}