HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions
tt::text_field_delegate Class Reference
Inheritance diagram for tt::text_field_delegate:
tt::default_text_field_delegate< T >

Public Types

using callback_ptr_type = std::shared_ptr<std::function<void()>>
 

Public Member Functions

virtual void init (text_field_widget const &sender) noexcept
 
virtual void deinit (text_field_widget const &sender) noexcept
 
virtual callback_ptr_type subscribe (text_field_widget &sender, callback_ptr_type const &callback_ptr) noexcept
 
template<typename Callback >
requires (std::is_invocable_v<Callback>)
callback_ptr_type subscribe (text_field_widget &sender, Callback &&callback) noexcept
 Subscribe a callback for notifying the widget of a data change.
 
virtual void unsubscribe (text_field_widget &sender, callback_ptr_type const &callback_ptr) noexcept
 
virtual std::optional< labelvalidate (text_field_widget &sender, std::string_view text) noexcept
 Validate the text field.
 
virtual std::string text (text_field_widget &sender) noexcept
 Get the text to show in the text field.
 
virtual void set_text (text_field_widget &sender, std::string_view text) noexcept
 Set the text as entered by the user.
 

Member Function Documentation

◆ set_text()

virtual void tt::text_field_delegate::set_text ( text_field_widget & sender,
std::string_view text )
inlinevirtualnoexcept

Set the text as entered by the user.

When the user causes a text field to commit, by pressing enter, tab, or clicking outside the field and when the text was validated the widget will call this function to commit the text with the delegate.

Precondition
text Must have been validated as correct.
Parameters
textThe text entered by the user.

Reimplemented in tt::default_text_field_delegate< T >.

◆ subscribe()

template<typename Callback >
requires (std::is_invocable_v<Callback>)
callback_ptr_type tt::text_field_delegate::subscribe ( text_field_widget & sender,
Callback && callback )
inlinenoexcept

Subscribe a callback for notifying the widget of a data change.

◆ text()

virtual std::string tt::text_field_delegate::text ( text_field_widget & sender)
inlinevirtualnoexcept

Get the text to show in the text field.

When the user is not editing the text the text-field will request what to show using this function.

Returns
The text to show in the text field.

Reimplemented in tt::default_text_field_delegate< T >.

◆ validate()

virtual std::optional< label > tt::text_field_delegate::validate ( text_field_widget & sender,
std::string_view text )
inlinevirtualnoexcept

Validate the text field.

Parameters
textThe text entered by the user into the text field.
Returns
no-value when valid, or a label to display to the user when invalid.

Reimplemented in tt::default_text_field_delegate< T >.


The documentation for this class was generated from the following file: