コード例 #1
0
def onA(pressed):
    global text, shift, cursorPos, _cbAccept, _cbCancel
    if pressed:
        if mode == 0:
            if cy == 2 and cx == 0:
                shift += 1
                if shift > 4:
                    shift = 0
            elif cy == 2 and cx == len(charMap[2]) - 1:
                # Backspace key
                if len(text) > 0:
                    # text = text[:-1]
                    if len(text) > cursorPos and cursorPos > 0:
                        text = text[0:cursorPos - 1:] + text[cursorPos::]
                        cursorPos -= 1
                    else:
                        text = text[:-1]
                        cursorPos -= 1
            else:
                offset = shift * 3
                if cursorPos >= len(text):
                    cursorPos += 1
                if charMap[cy + offset][cx] == "ENTER":
                    text += "\n"
                else:
                    text += charMap[cy + offset][cx]
                if shift == 1:
                    shift = 0
            _correctLocation()
            draw()
        if mode == 2:
            buttons.popMapping()
            _cbAccept(text)
コード例 #2
0
def _onB(pressed):
    global _TEXT, _TEXT_ORIG, _CB_ACCEPT, _CB_CANCEL, _CURSOR_X, _CURSOR_Y, _MODE
    if pressed:
        if _MODE == 2:
            _MODE = 3
            _draw()
            _buttons.popMapping()
            if _CB_CANCEL:
                _CB_CANCEL(_TEXT)
            else:
                _CB_ACCEPT(_TEXT_ORIG)
        else:
            if len(_TEXT) > 0:
                _TEXTPos = _calcPos()
                lenOfPrevLine = 0
                if len(_TEXT.split("\n")) > 0 and _CURSOR_Y > 0:
                    lenOfPrevLine = len(_TEXT.split("\n")[_CURSOR_Y - 1])
                if len(_TEXT) > _TEXTPos and _TEXTPos > 0:
                    _TEXT = _TEXT[0:_TEXTPos - 1:] + _TEXT[_TEXTPos::]
                    _CURSOR_X -= 1
                elif len(_TEXT) > 0:
                    _TEXT = _TEXT[:-1]
                    _CURSOR_X -= 1
                if _CURSOR_X < 0:
                    _CURSOR_X = lenOfPrevLine
                    _CURSOR_Y -= 1
                    if _CURSOR_Y < 0:
                        _CURSOR_Y = 0
        _draw()
コード例 #3
0
def _onA(pressed):
    global _TEXT, shift, _CURSOR_X, _CURSOR_Y, _XPOS, _MODE, _CB_ACCEPT, _CB_CANCEL
    if pressed:
        if _MODE == 0:
            _TEXTPos = _calcPos()
            if _TEXTPos >= len(_TEXT):
                _TEXT += _CHAR_MAP[_XPOS]
            else:
                _TEXT = _TEXT[:_TEXTPos] + _CHAR_MAP[_XPOS] + _TEXT[_TEXTPos:]
            _CURSOR_X += 1
            _draw()
        if _MODE == 1:
            _TEXTPos = _calcPos()
            if _TEXTPos >= len(_TEXT):
                _TEXT += "\n"
            else:
                _TEXT = _TEXT[:_TEXTPos] + "\n" + _TEXT[_TEXTPos:]
            _CURSOR_X = 0
            _CURSOR_Y += 1
            _draw()
        if _MODE == 2:
            _MODE = 3
            _draw()
            _buttons.popMapping()
            _CB_ACCEPT(_TEXT)
コード例 #4
0
def onB(pressed):
    global text, originalText, _cbAccept, _cbCancel
    if pressed and mode == 2:
        buttons.popMapping()
        if _cbCancel:
            _cbCancel(text)
        else:
            _cbAccept(originalText)
コード例 #5
0
def __onB(pressed):
    global text, originalText, _cbAccept, _cbCancel, active
    if pressed:
        buttons.popMapping()
        active = False
        if _cbCancel:
            _cbCancel(text)
        else:
            _cbAccept(originalText)
コード例 #6
0
def __onA(pressed):
    global text, active
    if pressed:
        buttons.popMapping()
        active = False
        _cbAccept(text)