Adding disable/enable functionality to text_area

This commit is contained in:
marcin 2018-03-28 21:02:53 +02:00
parent 3588955f0b
commit 9df4b21a26

View File

@ -107,6 +107,37 @@ impl TextArea {
self.with(|s| s.set_content(content))
}
/// Disables this view.
///
/// A disabled view cannot be selected.
pub fn disable(&mut self) {
self.enabled = false;
}
/// Disables this view.
///
/// Chainable variant.
pub fn disabled(self) -> Self {
self.with(Self::disable)
}
/// Re-enables this view.
pub fn enable(&mut self) {
self.enabled = true;
}
/// Re-enables this view.
///
/// Chainable variant.
pub fn enabled(self) -> Self {
self.with(Self::enable)
}
/// Returns `true` if this view is enabled.
pub fn is_enabled(&self) -> bool {
self.enabled
}
/// Finds the row containing the grapheme at the given offset
fn row_at(&self, offset: usize) -> usize {
debug!("Offset: {}", offset);