Guide API
Skip to main content

Options

Struct Options 

Source
pub struct Options {
    pub selectable: bool,
    pub top_select: bool,
    pub first_click: bool,
    pub framed: bool,
    pub pre_process: bool,
    pub post_process: bool,
    pub tileable: bool,
    pub center_x: bool,
    pub center_y: bool,
    pub validate: bool,
}
Expand description

The per-view option flags — fixed, build-time choices about how a view behaves (selectable, framed, centered, pre/post-process, …), as opposed to the live State bits.

Set these flags on ViewState::options before inserting the view into its owner. The most commonly needed flags are:

  • selectable = true — the view can receive focus (required for input widgets).
  • top_select = true — combined with selectable, brings windows to the front on mouse-click (set automatically by Window).
  • first_click = true — the click that selects the view is also delivered as a MouseDown; without it, the first click only selects.
  • pre_process = true — the view receives focused-chain events before the focused view (e.g. a menu bar that intercepts Alt-letter hotkeys).
  • post_process = true — the view receives focused-chain events after the focused view (plain-letter hotkeys for buttons, labels, and clusters).
  • center_x / center_y = true — the owner auto-centers the view’s bounds on that axis. Useful for dialogs placed without an exact position.

Dropped: the per-view back-buffer option (tvision-rs redraws the whole tree and diffs). The streaming-only version bits are dropped too.

§Turbo Vision heritage

Ports the of* flag family (views.h) as a struct-of-bools (deviation D5); each field names its of* source. The dropped options are ofBuffered (0x040) and the streaming-only ofVersion* bits.

Fields§

§selectable: bool

ofSelectable — the view can become the current/focused view.

All interactive widgets (buttons, input lines, list viewers, …) set this. A view without selectable is purely decorative: it never receives focus.

§top_select: bool

ofTopSelect — selecting the view moves it to the front of its owner.

Used by Window: clicking a window selects it and brings it to the top of the z-order simultaneously.

§first_click: bool

ofFirstClick — a selecting mouse-down is also passed through to the view.

Without this flag, the first click on an unfocused view only focuses it; with it, the click is also delivered as a MouseDown event so the view can react immediately (e.g. a button that fires on the first click).

§framed: bool

ofFramed — the view has a frame drawn around it.

Informs the owner that the view manages its own border; used by Frame so the owner can adjust layouts.

§pre_process: bool

ofPreProcess — the view sees focused-chain events before the focused view.

Set on views that must intercept events at the group level before the current child sees them (e.g. a menu bar intercepting Alt+letter hotkeys).

§post_process: bool

ofPostProcess — the view sees focused-chain events after the focused view.

Set on views that handle plain-letter accelerators (e.g. buttons and clusters), which fire only when no other view consumed the key first.

§tileable: bool

ofTileable — the view participates in tile/cascade layout.

Set on windows that should be included when the desktop tiles or cascades. Decorative or fixed-position windows leave this false.

§center_x: bool

ofCenterX — the view is centered horizontally in its owner.

The owner adjusts the view’s x position to center it. Combine with center_y (or use Options::centered) to center on both axes.

§center_y: bool

ofCenterY — the view is centered vertically in its owner.

The owner adjusts the view’s y position to center it.

§validate: bool

ofValidate — the view is asked to validate (valid(Command::RELEASED_FOCUS)) before losing focus.

When set, the group calls view.valid(Command::RELEASED_FOCUS) before allowing focus to move away. Return false from valid to keep focus locked (e.g. an input line with a required field).

Implementations§

Source§

impl Options

Source

pub fn centered(self) -> bool

ofCentered (ofCenterX | ofCenterY) — centered on both axes.

Returns true only when both center_x and center_y are set. Note that this is a read-only predicate, not a setter — assign both fields explicitly to enable centering.

Trait Implementations§

Source§

impl Clone for Options

Source§

fn clone(&self) -> Options

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Options

Source§

impl Debug for Options

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Options

Source§

fn default() -> Options

Returns the “default value” for a type. Read more
Source§

impl Eq for Options

Source§

impl Hash for Options

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Options

Source§

fn eq(&self, other: &Options) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Options

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CustomValue for T
where T: Any + Debug,

Source§

fn as_any_rc(self: Rc<T>) -> Rc<dyn Any>

Upcast Rc<Self> to Rc<dyn Any> so FieldValue::as_custom / FieldValue::value_as can downcast.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.