You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm currently trying to understand how to quit a SlidePrompt during the inputs. I saw you did a keyhandler.register but I can't implement it.
Does it have to be in the SlidePrompt class ? Can I put an keyhandler on my functions ?
For example, I have a login "form" and I want to cancel the process
deflogIn():
form=SlidePrompt([
Input("Enter your username: ",
word_color=_YELLOW
),
Input("Enter your password: ",
word_color=_YELLOW
),
])
result=form.launch()
I tested to add @keyhandler.register(charDef.INTERRUPT_KEY) above the function but it didn't work, so maybe a clearer explanation on how to achieve this could be great !
Thanks 😄
The text was updated successfully, but these errors were encountered:
Hi @pommepommee , you could refer to DOCUMENTATION.md and ./examples/check.py to see how keyhandler works in the general case.
However, after playing with your example for a while, I found that the keyhandler could not solve your case.
The main reason is that Input calls myInput function, and myInput calls utils.getchar. The getchar function essentially captures all keyboard events.
# in client.myInput
def input(self):
while True:
c = utils.getchar()
i = c if c == UNDEFINED_KEY else ord(c)
if i == NEWLINE_KEY:
utils.forceWrite('\n')
return self.getInput()
I believe the only thing you could do (for now) is modify the input function of myInput so that it handles charDef.INTERRUPT_KEY, probably like the following:
# in client.myInput
def input(self):
while True:
c = utils.getchar()
i = c if c == UNDEFINED_KEY else ord(c)
if i == INTERRUPT_KEY:
#do something
if i == NEWLINE_KEY:
utils.forceWrite('\n')
return self.getInput()
Hi, I'm currently trying to understand how to quit a SlidePrompt during the inputs. I saw you did a keyhandler.register but I can't implement it.
Does it have to be in the SlidePrompt class ? Can I put an keyhandler on my functions ?
For example, I have a login "form" and I want to cancel the process
I tested to add
@keyhandler.register(charDef.INTERRUPT_KEY)
above the function but it didn't work, so maybe a clearer explanation on how to achieve this could be great !Thanks 😄
The text was updated successfully, but these errors were encountered: