When choosing an option call the callback after the popup window is removed. This ensures the active window is unchanged when the callback is called. Fixes #5488
This commit is contained in:
parent
902e94ceac
commit
19799bd538
@ -782,8 +782,12 @@ class Boss:
|
|||||||
hidden_text_placeholder: str = 'HIDDEN_TEXT_PLACEHOLDER', # placeholder text to insert in to message
|
hidden_text_placeholder: str = 'HIDDEN_TEXT_PLACEHOLDER', # placeholder text to insert in to message
|
||||||
unhide_key: str = 'u', # key to press to unhide hidden text
|
unhide_key: str = 'u', # key to press to unhide hidden text
|
||||||
) -> Optional[Window]:
|
) -> Optional[Window]:
|
||||||
|
result: str = ''
|
||||||
|
|
||||||
def callback_(res: Dict[str, Any], x: int, boss: Boss) -> None:
|
def callback_(res: Dict[str, Any], x: int, boss: Boss) -> None:
|
||||||
callback(res.get('response') or '')
|
nonlocal result
|
||||||
|
result = res.get('response') or ''
|
||||||
|
|
||||||
if hidden_text:
|
if hidden_text:
|
||||||
msg = msg.replace(hidden_text, hidden_text_placeholder)
|
msg = msg.replace(hidden_text, hidden_text_placeholder)
|
||||||
cmd = ['--type=choices', '--message', msg]
|
cmd = ['--type=choices', '--message', msg]
|
||||||
@ -796,7 +800,14 @@ class Boss:
|
|||||||
input_data = hidden_text
|
input_data = hidden_text
|
||||||
else:
|
else:
|
||||||
input_data = None
|
input_data = None
|
||||||
ans = self.run_kitten_with_metadata('ask', cmd, window=window, custom_callback=callback_, input_data=input_data, default_data={'response': ''})
|
|
||||||
|
def on_popup_overlay_removal(wid: int, boss: Boss) -> None:
|
||||||
|
callback(result)
|
||||||
|
|
||||||
|
ans = self.run_kitten_with_metadata(
|
||||||
|
'ask', cmd, window=window, custom_callback=callback_, input_data=input_data, default_data={'response': ''},
|
||||||
|
action_on_removal=on_popup_overlay_removal
|
||||||
|
)
|
||||||
if isinstance(ans, Window):
|
if isinstance(ans, Window):
|
||||||
return ans
|
return ans
|
||||||
return None
|
return None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user