rr- / urwid_readline

readline text edit for urwid
MIT License
27 stars 11 forks source link

Add feature to block keypress using `block_keypress` property. #9

Closed amanagr closed 5 years ago

amanagr commented 5 years ago

@rr- this will be useful for blocking inputs temporarily or permanently to some edit boxes.

rr- commented 5 years ago

Thanks for the pull request, but this is pretty obscure feature which I don't see the usage for, so I'm going to reject it (I'm open to discussion, though). Note that if you do need this behavior in your project, you can still have it - all you need is to subclass ReadlineEdit like so (not tested):

class MyReadlineEdit(ReadlineEdit):
    def __init__(self, *args, **kwargs):
        self.block_keypress = False
        super().__init__(self, *args, **kwargs)

    def keypress(self, size, key):
        if self.block_keypress:
            return
        return super().keypress(size, key)