File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1670,6 +1670,9 @@ function TextField:draw(dt)
16701670end
16711671
16721672function TextField :setCursorPosition (pos )
1673+ if pos > # self .text then
1674+ pos = # self .text
1675+ end
16731676 self .cursorPosition = pos
16741677
16751678 if pos < self .textOffset then
@@ -1756,7 +1759,9 @@ function TextField:keyEvent(keyCode, pressed)
17561759
17571760 if # key == 1 then -- Type a character
17581761 self .text = text :sub (1 , cursorPos ) .. key .. text :sub (cursorPos + 1 )
1759- self :setCursorPosition (cursorPos + 1 )
1762+ if text ~= self .text then
1763+ self :setCursorPosition (cursorPos + 1 )
1764+ end
17601765 else -- Special character
17611766 if key == " backspace" then
17621767 if cursorPos > 0 then
@@ -2377,6 +2382,9 @@ function List:removeItem(target)
23772382 return nil , - 1
23782383 end
23792384 else -- Remove by item
2385+ if target == nil then
2386+ return nil
2387+ end
23802388 item = target
23812389 index = PtUtil .removeObject (self .items , item )
23822390 if index == - 1 then
Original file line number Diff line number Diff line change @@ -159,6 +159,9 @@ function List:removeItem(target)
159159 return nil , - 1
160160 end
161161 else -- Remove by item
162+ if target == nil then
163+ return nil
164+ end
162165 item = target
163166 index = PtUtil .removeObject (self .items , item )
164167 if index == - 1 then
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ function Panel:add(child)
3737end
3838
3939--- Sets the layout manager for this Panel.
40+ -- THIS IS WIP. THE API IS LIKELY TO CHANGE.
4041-- @param layout The new layout manager for this panel, or nil to clear the
4142-- layout manager.
4243function Panel :setLayoutManager (layout )
Original file line number Diff line number Diff line change 130130-- @param pos The new position for the cursor, where 0 is the beginning of the
131131-- field.
132132function TextField :setCursorPosition (pos )
133+ if pos > # self .text then
134+ pos = # self .text
135+ end
133136 self .cursorPosition = pos
134137
135138 if pos < self .textOffset then
@@ -219,7 +222,9 @@ function TextField:keyEvent(keyCode, pressed)
219222
220223 if # key == 1 then -- Type a character
221224 self .text = text :sub (1 , cursorPos ) .. key .. text :sub (cursorPos + 1 )
222- self :setCursorPosition (cursorPos + 1 )
225+ if text ~= self .text then
226+ self :setCursorPosition (cursorPos + 1 )
227+ end
223228 else -- Special character
224229 if key == " backspace" then
225230 if cursorPos > 0 then
You can’t perform that action at this time.
0 commit comments