-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
String: Add .is_empty() and .length() Methods
Introduce two new methods for string properties in .slint: - .is_empty(): Checks if a string is empty. - .length(): Retrieves the length of the string. These additions enhance functionality and improve convenience when working with string properties.
- Loading branch information
Showing
8 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 | ||
|
||
export component TestCase { | ||
in property<string> hello: "hello"; | ||
in property<string> empty; | ||
|
||
out property<bool> empty_is_empty: empty.is-empty(); | ||
out property<bool> hello_is_not_empty: !hello.is-empty(); | ||
out property<bool> test_is_empty: empty_is_empty && hello_is_not_empty; | ||
out property<int> hello_length: hello.length(); | ||
out property<int> empty_length: empty.length(); | ||
out property<bool> hello_length_is_5: hello_length == 5; | ||
out property<bool> empty_length_is_0: empty_length == 0; | ||
out property<bool> test_length: hello_length_is_5 && empty_length_is_0; | ||
out property<bool> test: test_is_empty && test_length; | ||
} | ||
|
||
|
||
/* | ||
```cpp | ||
auto handle = TestCase::create(); | ||
const TestCase &instance = *handle; | ||
assert(instance.get_test()); | ||
``` | ||
```rust | ||
let instance = TestCase::new().unwrap(); | ||
assert!(instance.get_test()); | ||
``` | ||
```js | ||
var instance = new slint.TestCase({}); | ||
assert(instance.test); | ||
``` | ||
*/ |