Skip to content

Commit

Permalink
Added rejected to textedit (#6662)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheColorRed authored Oct 31, 2024
1 parent 5bd6c4b commit 908580b
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 30 deletions.
1 change: 1 addition & 0 deletions docs/reference/src/language/widgets/textedit.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ shortcut will be implemented in a future version: <https://github.com/slint-ui/s
### Callbacks

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

### Example

Expand Down
17 changes: 11 additions & 6 deletions internal/compiler/widgets/common/textedit-base.slint
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,29 @@ export component TextEditBase inherits Rectangle {
in property <brush> 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();
}

Expand All @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions internal/compiler/widgets/cosmic/textedit.slint
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export component TextEdit {
in-out property <length> 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;
Expand Down
18 changes: 12 additions & 6 deletions internal/compiler/widgets/cupertino/textedit.slint
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,34 @@ export component TextEdit {
in property <string> 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();
}

Expand Down Expand Up @@ -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));
Expand Down
14 changes: 8 additions & 6 deletions internal/compiler/widgets/fluent/textedit.slint
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,34 @@ export component TextEdit {
in-out property <length> 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();
}

Expand Down
14 changes: 8 additions & 6 deletions internal/compiler/widgets/material/textedit.slint
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,34 @@ export component TextEdit {
in-out property <length> 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();
}

Expand Down
14 changes: 8 additions & 6 deletions internal/compiler/widgets/qt/textedit.slint
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,34 @@ export component TextEdit {
in-out property <length> 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();
}

Expand Down

0 comments on commit 908580b

Please sign in to comment.