MCPcopy
hub / github.com/Textualize/textual / _select_command

Method _select_command

src/textual/command.py:1190–1209  ·  view source on GitHub ↗

React to a command being selected from the dropdown. Args: event: The option selection event.

(self, event: OptionList.OptionSelected)

Source from the content-addressed store, hash-verified

1188
1189 @on(OptionList.OptionSelected)
1190 def _select_command(self, event: OptionList.OptionSelected) -> None:
1191 """React to a command being selected from the dropdown.
1192
1193 Args:
1194 event: The option selection event.
1195 """
1196 event.stop()
1197 self._cancel_gather_commands()
1198 input = self.query_one(CommandInput)
1199 with self.prevent(Input.Changed):
1200 assert isinstance(event.option, Command)
1201 hit = event.option.hit
1202 input.value = str(hit.text)
1203 self._selected_command = hit
1204 input.action_end()
1205 self._list_visible = False
1206 self.query_one(CommandList).clear_options()
1207 self._hit_count = 0
1208 if self.run_on_select:
1209 self._select_or_command()
1210
1211 @on(Input.Submitted)
1212 @on(Button.Pressed)

Callers

nothing calls this directly

Calls 7

_select_or_commandMethod · 0.95
query_oneMethod · 0.80
preventMethod · 0.80
action_endMethod · 0.80
stopMethod · 0.45
clear_optionsMethod · 0.45

Tested by

no test coverage detected