diff options
author | 2024-07-24 14:52:01 +0200 | |
---|---|---|
committer | 2024-07-24 14:52:01 +0200 | |
commit | e9e06c8fe2ef291b04f6059a841ceb999455bea8 (patch) | |
tree | 7a8d1d636d69125762045e0ca431359810064b75 /core | |
parent | a5b1a1df548a9bfeefc3e422defe6d67cf61c170 (diff) | |
download | iced-e9e06c8fe2ef291b04f6059a841ceb999455bea8.tar.gz iced-e9e06c8fe2ef291b04f6059a841ceb999455bea8.tar.bz2 iced-e9e06c8fe2ef291b04f6059a841ceb999455bea8.zip |
Add `placeholder` support to `text_editor` widget
Diffstat (limited to '')
-rw-r--r-- | core/src/renderer/null.rs | 4 | ||||
-rw-r--r-- | core/src/text/editor.rs | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs index 7aa3aafb..d8d3c50a 100644 --- a/core/src/renderer/null.rs +++ b/core/src/renderer/null.rs @@ -118,6 +118,10 @@ impl text::Editor for () { fn with_text(_text: &str) -> Self {} + fn is_empty(&self) -> bool { + true + } + fn cursor(&self) -> text::editor::Cursor { text::editor::Cursor::Caret(Point::ORIGIN) } diff --git a/core/src/text/editor.rs b/core/src/text/editor.rs index aea00921..135707d1 100644 --- a/core/src/text/editor.rs +++ b/core/src/text/editor.rs @@ -13,6 +13,9 @@ pub trait Editor: Sized + Default { /// Creates a new [`Editor`] laid out with the given text. fn with_text(text: &str) -> Self; + /// Returns true if the [`Editor`] has no contents. + fn is_empty(&self) -> bool; + /// Returns the current [`Cursor`] of the [`Editor`]. fn cursor(&self) -> Cursor; |