mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add control to option list messages.
This commit is contained in:
@@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- The DataTable cursor is now scrolled into view when the cursor coordinate is changed programmatically https://github.com/Textualize/textual/issues/2459
|
||||
- run_worker exclusive parameter is now `False` by default https://github.com/Textualize/textual/pull/2470
|
||||
|
||||
### Added
|
||||
|
||||
- Added the `control` property to messages
|
||||
- `OptionList.OptionHighlighted` and `OptionList.OptionSelected`
|
||||
|
||||
## [0.23.0] - 2023-05-03
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -90,18 +90,7 @@ tables](https://rich.readthedocs.io/en/latest/tables.html):
|
||||
- [OptionList.OptionHighlight][textual.widgets.OptionList.OptionHighlighted]
|
||||
- [OptionList.OptionSelected][textual.widgets.OptionList.OptionSelected]
|
||||
|
||||
Both of the messages above inherit from this common base, which makes
|
||||
available the following properties relating to the `OptionList` and the
|
||||
related `Option`:
|
||||
|
||||
### Common message properties
|
||||
|
||||
Both of the above messages provide the following properties:
|
||||
|
||||
#### ::: textual.widgets.OptionList.OptionMessage.option
|
||||
#### ::: textual.widgets.OptionList.OptionMessage.option_id
|
||||
#### ::: textual.widgets.OptionList.OptionMessage.option_index
|
||||
#### ::: textual.widgets.OptionList.OptionMessage.option_list
|
||||
Both of the messages above inherit from the common base [`OptionList`][textual.widgets.OptionList.OptionMessage], so refer to its documentation to see what attributes are available.
|
||||
|
||||
## Bindings
|
||||
|
||||
|
||||
@@ -253,6 +253,15 @@ class OptionList(ScrollView, can_focus=True):
|
||||
self.option_index: int = index
|
||||
"""The index of the option that the message relates to."""
|
||||
|
||||
@property
|
||||
def control(self) -> OptionList:
|
||||
"""The option list that sent the message.
|
||||
|
||||
This is an alias for [`OptionMessage.option_list`][textual.widgets.OptionList.OptionMessage.option_list]
|
||||
and is used by the [`on`][textual.on] decorator.
|
||||
"""
|
||||
return self.option_list
|
||||
|
||||
def __rich_repr__(self) -> Result:
|
||||
yield "option_list", self.option_list
|
||||
yield "option", self.option
|
||||
|
||||
Reference in New Issue
Block a user