Open pommepommee opened 3 years ago
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()
I plan to completely rewrite the myInput
function to solve your issue for good. Please stay tuned for the latest release.
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 😄