def getSelectionLength(self):
        element = self.getElement()
        try:
            return element.selectionEnd - element.selectionStart
        except:
            return 0

    # have to override Focus here for TextBoxBase
    # because FocusWidget (actually FocusMixin) assumes that
    # CreateFocusable has been used to create the element.
    # in "input box" type scenarios, it hasn't: it's created
    # by TextBox class etc.
dataset/ETHPy150Open pyjs/pyjs/pyjswidgets/pyjamas/ui/TextBoxBase.py/TextBoxBase.getSelectionLength/original