From 908580b951713d31d4584223a359c38f66c528a2 Mon Sep 17 00:00:00 2001 From: Ryan Naddy Date: Thu, 31 Oct 2024 10:23:50 -0500 Subject: [PATCH] Added rejected to textedit (#6662) --- .../reference/src/language/widgets/textedit.md | 1 + .../widgets/common/textedit-base.slint | 17 +++++++++++------ .../compiler/widgets/cosmic/textedit.slint | 2 ++ .../compiler/widgets/cupertino/textedit.slint | 18 ++++++++++++------ .../compiler/widgets/fluent/textedit.slint | 14 ++++++++------ .../compiler/widgets/material/textedit.slint | 14 ++++++++------ internal/compiler/widgets/qt/textedit.slint | 14 ++++++++------ 7 files changed, 50 insertions(+), 30 deletions(-) diff --git a/docs/reference/src/language/widgets/textedit.md b/docs/reference/src/language/widgets/textedit.md index b0be765429e..8e170e74859 100644 --- a/docs/reference/src/language/widgets/textedit.md +++ b/docs/reference/src/language/widgets/textedit.md @@ -31,6 +31,7 @@ shortcut will be implemented in a future version: placeholder-color; callback edited(/* text */ string); + callback rejected(/* text */ string); - public function set-selection-offsets(start: int,end: int){ + public function set-selection-offsets(start: int, end: int) { text-input.set-selection-offsets(start, end); } - public function select-all(){ + public function select-all() { text-input.select-all(); } - public function clear-selection(){ + public function clear-selection() { text-input.clear-selection(); } - public function cut(){ + public function cut() { text-input.cut(); } - public function copy(){ + public function copy() { text-input.copy(); } - public function paste(){ + public function paste() { text-input.paste(); } @@ -75,6 +76,10 @@ export component TextEditBase inherits Rectangle { root.edited(self.text); } + rejected => { + root.rejected(self.text); + } + cursor-position-changed(cpos) => { if (cpos.x + root.viewport-x < 12px) { root.viewport-x = min(0px, max(parent.visible-width - self.width, - cpos.x + 12px)); diff --git a/internal/compiler/widgets/cosmic/textedit.slint b/internal/compiler/widgets/cosmic/textedit.slint index 3a44be0cad1..1d730d54671 100644 --- a/internal/compiler/widgets/cosmic/textedit.slint +++ b/internal/compiler/widgets/cosmic/textedit.slint @@ -22,6 +22,8 @@ export component TextEdit { in-out property viewport-height <=> base.viewport-height; callback edited <=> base.edited; + callback rejected <=> base.rejected; + accessible-role: AccessibleRole.text-input; accessible-enabled: root.enabled; accessible-value <=> text; diff --git a/internal/compiler/widgets/cupertino/textedit.slint b/internal/compiler/widgets/cupertino/textedit.slint index 2f59099e4ac..3603d3a239b 100644 --- a/internal/compiler/widgets/cupertino/textedit.slint +++ b/internal/compiler/widgets/cupertino/textedit.slint @@ -78,32 +78,34 @@ export component TextEdit { in property placeholder-text; callback edited(/* text */ string); + callback rejected(/* text */ string); + accessible-role: AccessibleRole.text-input; accessible-enabled: root.enabled; accessible-value <=> text; accessible-placeholder-text: text == "" ? placeholder-text : ""; - public function set-selection-offsets(start: int,end: int){ + public function set-selection-offsets(start: int, end: int) { text-input.set-selection-offsets(start, end); } - public function select-all(){ + public function select-all() { text-input.select-all(); } - public function clear-selection(){ + public function clear-selection() { text-input.clear-selection(); } - public function cut(){ + public function cut() { text-input.cut(); } - public function copy(){ + public function copy() { text-input.copy(); } - public function paste(){ + public function paste() { text-input.paste(); } @@ -157,6 +159,10 @@ export component TextEdit { root.edited(self.text); } + rejected => { + root.rejected(self.text); + } + cursor-position-changed(cpos) => { if (cpos.x + root.viewport-x < 12px) { root.viewport-x = min(0px, max(parent.visible-width - self.width, - cpos.x + 12px)); diff --git a/internal/compiler/widgets/fluent/textedit.slint b/internal/compiler/widgets/fluent/textedit.slint index 3b1f486625a..13e986ba8c6 100644 --- a/internal/compiler/widgets/fluent/textedit.slint +++ b/internal/compiler/widgets/fluent/textedit.slint @@ -22,32 +22,34 @@ export component TextEdit { in-out property viewport-height <=> base.viewport-height; callback edited <=> base.edited; + callback rejected <=> base.rejected; + accessible-role: AccessibleRole.text-input; accessible-enabled: root.enabled; accessible-value <=> text; accessible-placeholder-text: text == "" ? placeholder-text : ""; - public function set-selection-offsets(start: int,end: int){ + public function set-selection-offsets(start: int, end: int) { base.set-selection-offsets(start, end); } - public function select-all(){ + public function select-all() { base.select-all(); } - public function clear-selection(){ + public function clear-selection() { base.clear-selection(); } - public function cut(){ + public function cut() { base.cut(); } - public function copy(){ + public function copy() { base.copy(); } - public function paste(){ + public function paste() { base.paste(); } diff --git a/internal/compiler/widgets/material/textedit.slint b/internal/compiler/widgets/material/textedit.slint index c72362b43f2..807be005c4e 100644 --- a/internal/compiler/widgets/material/textedit.slint +++ b/internal/compiler/widgets/material/textedit.slint @@ -22,32 +22,34 @@ export component TextEdit { in-out property viewport-height <=> base.viewport-height; callback edited <=> base.edited; + callback rejected <=> base.rejected; + accessible-role: AccessibleRole.text-input; accessible-enabled: root.enabled; accessible-value <=> text; accessible-placeholder-text: text == "" ? placeholder-text : ""; - public function set-selection-offsets(start: int,end: int){ + public function set-selection-offsets(start: int, end: int) { base.set-selection-offsets(start, end); } - public function select-all(){ + public function select-all() { base.select-all(); } - public function clear-selection(){ + public function clear-selection() { base.clear-selection(); } - public function cut(){ + public function cut() { base.cut(); } - public function copy(){ + public function copy() { base.copy(); } - public function paste(){ + public function paste() { base.paste(); } diff --git a/internal/compiler/widgets/qt/textedit.slint b/internal/compiler/widgets/qt/textedit.slint index 66ff992ac85..c08773771ac 100644 --- a/internal/compiler/widgets/qt/textedit.slint +++ b/internal/compiler/widgets/qt/textedit.slint @@ -21,32 +21,34 @@ export component TextEdit { in-out property viewport-height <=> base.viewport-height; callback edited <=> base.edited; + callback rejected <=> base.rejected; + accessible-role: AccessibleRole.text-input; accessible-enabled: root.enabled; accessible-value <=> text; accessible-placeholder-text: text == "" ? placeholder-text : ""; - public function set-selection-offsets(start: int,end: int){ + public function set-selection-offsets(start: int, end: int) { base.set-selection-offsets(start, end); } - public function select-all(){ + public function select-all() { base.select-all(); } - public function clear-selection(){ + public function clear-selection() { base.clear-selection(); } - public function cut(){ + public function cut() { base.cut(); } - public function copy(){ + public function copy() { base.copy(); } - public function paste(){ + public function paste() { base.paste(); }