/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27

« back to all changes in this revision

Viewing changes to zoetrope/ui/textinput.lua

  • Committer: Josh C
  • Date: 2014-07-04 22:05:15 UTC
  • Revision ID: josh@9ix.org-20140704220515-1lyoulmix915mlcp
propagate scaling / translate properly

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
                        end
66
66
 
67
67
                        -- handle movement keys that repeat
68
 
                        -- we have to simulate repeat rates manually :(
69
68
 
70
 
                        local delay, rate = love.keyboard.getKeyRepeat()
71
69
                        local frameAction
72
70
 
73
71
                        for _, key in pairs{'backspace', 'delete', 'left', 'right'} do
74
72
                                if the.keys:pressed(key) then
75
 
                                        if self._repeatKey == key then
76
 
                                                self._repeatTimer = self._repeatTimer + elapsed
77
 
                                                
78
 
                                                -- if we've made it past the maximum delay, then
79
 
                                                -- we reset the timer and take action
80
 
 
81
 
                                                if self._repeatTimer > delay + rate then
82
 
                                                        self._repeatTimer = delay
83
 
                                                        frameAction = key
84
 
                                                end
85
 
                                        else
86
 
                                                -- we've just started holding down the key
87
 
 
88
 
                                                self._repeatKey = key
89
 
                                                self._repeatTimer = 0
90
 
                                                frameAction = key
91
 
                                        end
92
 
                                else
93
 
                                        if self._repeatKey == key then
94
 
                                                self._repeatKey = nil
 
73
                                        frameAction = key
 
74
                                        if the.keys:alreadyHandled(key) then
 
75
                                                frameAction = nil
95
76
                                        end
96
77
                                end
97
78
                        end
98
79
 
 
80
 
99
81
                        if frameAction == 'backspace' and self.caret > 0 then
100
82
                                self.text = string.sub(self.text, 1, self.caret - 1) .. string.sub(self.text, self.caret + 1)
101
83
                                self.caret = self.caret - 1