From 3ab797503b4259520cebce119ac0b2389eaf930f Mon Sep 17 00:00:00 2001 From: Ethan Knox Date: Mon, 16 Sep 2024 14:12:31 -0400 Subject: [PATCH 1/2] added args val for callback on top of text --- textcomplete/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/textcomplete/__init__.py b/textcomplete/__init__.py index 38a0bf8..966526b 100644 --- a/textcomplete/__init__.py +++ b/textcomplete/__init__.py @@ -13,6 +13,7 @@ Optional, TypedDict, TypeVar, + Tuple, Union, ) @@ -133,6 +134,7 @@ def textcomplete( stop_enter_propagation: bool = False, dynamic_width: bool = True, dropdown_style: str = "", + args: Optional[Tuple] = tuple(), ) -> Optional[TextcompleteResult]: # Call through to our private component function. Arguments we pass here # will be sent to the frontend, where they'll be available in an "args" @@ -164,7 +166,7 @@ def textcomplete( ) if on_select and result: - on_select(result) + on_select(result, *args) # We could modify the value returned from the component if we wanted. # There's no need to do this in our simple example - but it's an option. From b83789a8931b342c8eb189f771fc7bde68aa8c25 Mon Sep 17 00:00:00 2001 From: Ethan Knox Date: Mon, 16 Sep 2024 17:14:39 -0400 Subject: [PATCH 2/2] need key for multiple instances too --- textcomplete/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/textcomplete/__init__.py b/textcomplete/__init__.py index 966526b..591cd6d 100644 --- a/textcomplete/__init__.py +++ b/textcomplete/__init__.py @@ -135,6 +135,7 @@ def textcomplete( dynamic_width: bool = True, dropdown_style: str = "", args: Optional[Tuple] = tuple(), + key: Optional[str] = None, ) -> Optional[TextcompleteResult]: # Call through to our private component function. Arguments we pass here # will be sent to the frontend, where they'll be available in an "args" @@ -163,6 +164,7 @@ def textcomplete( strategies=[strategy.to_dict() for strategy in strategies], dropdown_option=dropdown_option, stop_enter_propagation=stop_enter_propagation, + key=key, ) if on_select and result: