Skip to content

Commit 908580b

Browse files
authored
Added rejected to textedit (#6662)
1 parent 5bd6c4b commit 908580b

File tree

7 files changed

+50
-30
lines changed

7 files changed

+50
-30
lines changed

docs/reference/src/language/widgets/textedit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ shortcut will be implemented in a future version: <https://github.com/slint-ui/s
3131
### Callbacks
3232

3333
- **`edited(string)`**: Emitted when the text has changed because the user modified it
34+
- **`rejected()`**: Emitted when the user pressed the escape key
3435

3536
### Example
3637

internal/compiler/widgets/common/textedit-base.slint

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,29 @@ export component TextEditBase inherits Rectangle {
2929
in property <brush> placeholder-color;
3030

3131
callback edited(/* text */ string);
32+
callback rejected(/* text */ string);
3233

33-
public function set-selection-offsets(start: int,end: int){
34+
public function set-selection-offsets(start: int, end: int) {
3435
text-input.set-selection-offsets(start, end);
3536
}
3637

37-
public function select-all(){
38+
public function select-all() {
3839
text-input.select-all();
3940
}
4041

41-
public function clear-selection(){
42+
public function clear-selection() {
4243
text-input.clear-selection();
4344
}
4445

45-
public function cut(){
46+
public function cut() {
4647
text-input.cut();
4748
}
4849

49-
public function copy(){
50+
public function copy() {
5051
text-input.copy();
5152
}
5253

53-
public function paste(){
54+
public function paste() {
5455
text-input.paste();
5556
}
5657

@@ -75,6 +76,10 @@ export component TextEditBase inherits Rectangle {
7576
root.edited(self.text);
7677
}
7778

79+
rejected => {
80+
root.rejected(self.text);
81+
}
82+
7883
cursor-position-changed(cpos) => {
7984
if (cpos.x + root.viewport-x < 12px) {
8085
root.viewport-x = min(0px, max(parent.visible-width - self.width, - cpos.x + 12px));

internal/compiler/widgets/cosmic/textedit.slint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export component TextEdit {
2222
in-out property <length> viewport-height <=> base.viewport-height;
2323

2424
callback edited <=> base.edited;
25+
callback rejected <=> base.rejected;
26+
2527
accessible-role: AccessibleRole.text-input;
2628
accessible-enabled: root.enabled;
2729
accessible-value <=> text;

internal/compiler/widgets/cupertino/textedit.slint

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,32 +78,34 @@ export component TextEdit {
7878
in property <string> placeholder-text;
7979

8080
callback edited(/* text */ string);
81+
callback rejected(/* text */ string);
82+
8183
accessible-role: AccessibleRole.text-input;
8284
accessible-enabled: root.enabled;
8385
accessible-value <=> text;
8486
accessible-placeholder-text: text == "" ? placeholder-text : "";
8587

86-
public function set-selection-offsets(start: int,end: int){
88+
public function set-selection-offsets(start: int, end: int) {
8789
text-input.set-selection-offsets(start, end);
8890
}
8991

90-
public function select-all(){
92+
public function select-all() {
9193
text-input.select-all();
9294
}
9395

94-
public function clear-selection(){
96+
public function clear-selection() {
9597
text-input.clear-selection();
9698
}
9799

98-
public function cut(){
100+
public function cut() {
99101
text-input.cut();
100102
}
101103

102-
public function copy(){
104+
public function copy() {
103105
text-input.copy();
104106
}
105107

106-
public function paste(){
108+
public function paste() {
107109
text-input.paste();
108110
}
109111

@@ -157,6 +159,10 @@ export component TextEdit {
157159
root.edited(self.text);
158160
}
159161

162+
rejected => {
163+
root.rejected(self.text);
164+
}
165+
160166
cursor-position-changed(cpos) => {
161167
if (cpos.x + root.viewport-x < 12px) {
162168
root.viewport-x = min(0px, max(parent.visible-width - self.width, - cpos.x + 12px));

internal/compiler/widgets/fluent/textedit.slint

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,34 @@ export component TextEdit {
2222
in-out property <length> viewport-height <=> base.viewport-height;
2323

2424
callback edited <=> base.edited;
25+
callback rejected <=> base.rejected;
26+
2527
accessible-role: AccessibleRole.text-input;
2628
accessible-enabled: root.enabled;
2729
accessible-value <=> text;
2830
accessible-placeholder-text: text == "" ? placeholder-text : "";
2931

30-
public function set-selection-offsets(start: int,end: int){
32+
public function set-selection-offsets(start: int, end: int) {
3133
base.set-selection-offsets(start, end);
3234
}
3335

34-
public function select-all(){
36+
public function select-all() {
3537
base.select-all();
3638
}
3739

38-
public function clear-selection(){
40+
public function clear-selection() {
3941
base.clear-selection();
4042
}
4143

42-
public function cut(){
44+
public function cut() {
4345
base.cut();
4446
}
4547

46-
public function copy(){
48+
public function copy() {
4749
base.copy();
4850
}
4951

50-
public function paste(){
52+
public function paste() {
5153
base.paste();
5254
}
5355

internal/compiler/widgets/material/textedit.slint

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,34 @@ export component TextEdit {
2222
in-out property <length> viewport-height <=> base.viewport-height;
2323

2424
callback edited <=> base.edited;
25+
callback rejected <=> base.rejected;
26+
2527
accessible-role: AccessibleRole.text-input;
2628
accessible-enabled: root.enabled;
2729
accessible-value <=> text;
2830
accessible-placeholder-text: text == "" ? placeholder-text : "";
2931

30-
public function set-selection-offsets(start: int,end: int){
32+
public function set-selection-offsets(start: int, end: int) {
3133
base.set-selection-offsets(start, end);
3234
}
3335

34-
public function select-all(){
36+
public function select-all() {
3537
base.select-all();
3638
}
3739

38-
public function clear-selection(){
40+
public function clear-selection() {
3941
base.clear-selection();
4042
}
4143

42-
public function cut(){
44+
public function cut() {
4345
base.cut();
4446
}
4547

46-
public function copy(){
48+
public function copy() {
4749
base.copy();
4850
}
4951

50-
public function paste(){
52+
public function paste() {
5153
base.paste();
5254
}
5355

internal/compiler/widgets/qt/textedit.slint

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,34 @@ export component TextEdit {
2121
in-out property <length> viewport-height <=> base.viewport-height;
2222

2323
callback edited <=> base.edited;
24+
callback rejected <=> base.rejected;
25+
2426
accessible-role: AccessibleRole.text-input;
2527
accessible-enabled: root.enabled;
2628
accessible-value <=> text;
2729
accessible-placeholder-text: text == "" ? placeholder-text : "";
2830

29-
public function set-selection-offsets(start: int,end: int){
31+
public function set-selection-offsets(start: int, end: int) {
3032
base.set-selection-offsets(start, end);
3133
}
3234

33-
public function select-all(){
35+
public function select-all() {
3436
base.select-all();
3537
}
3638

37-
public function clear-selection(){
39+
public function clear-selection() {
3840
base.clear-selection();
3941
}
4042

41-
public function cut(){
43+
public function cut() {
4244
base.cut();
4345
}
4446

45-
public function copy(){
47+
public function copy() {
4648
base.copy();
4749
}
4850

49-
public function paste(){
51+
public function paste() {
5052
base.paste();
5153
}
5254

0 commit comments

Comments
 (0)