|
|
|
@ -26,16 +26,13 @@ end
|
|
|
|
|
|
|
|
|
|
STANDARDSCROLL = {
|
|
|
|
|
STANDARDSCROLL_UP = -1,
|
|
|
|
|
KEYBOARD_CURSOR_UP = -1,
|
|
|
|
|
STANDARDSCROLL_DOWN = 1,
|
|
|
|
|
KEYBOARD_CURSOR_DOWN = 1,
|
|
|
|
|
STANDARDSCROLL_PAGEUP = '-page',
|
|
|
|
|
KEYBOARD_CURSOR_UP_FAST = '-page',
|
|
|
|
|
STANDARDSCROLL_PAGEDOWN = '+page',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SECONDSCROLL = {
|
|
|
|
|
SECONDSCROLL_UP = -1,
|
|
|
|
|
SECONDSCROLL_DOWN = 1,
|
|
|
|
|
SECONDSCROLL_PAGEUP = '-page',
|
|
|
|
|
SECONDSCROLL_PAGEDOWN = '+page',
|
|
|
|
|
KEYBOARD_CURSOR_DOWN_FAST = '+page',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
------------
|
|
|
|
@ -366,8 +363,10 @@ function Panel:setKeyboardDragEnabled(enabled)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if enabled then
|
|
|
|
|
local kbd_get_pos = function() return {x=0, y=0} end
|
|
|
|
|
Panel_begin_drag(self, kbd_get_pos())
|
|
|
|
|
local kbd_get_pos = function()
|
|
|
|
|
return {x=self.frame_rect.x1, y=self.frame_rect.y1}
|
|
|
|
|
end
|
|
|
|
|
Panel_begin_drag(self)
|
|
|
|
|
self.kbd_get_pos = kbd_get_pos
|
|
|
|
|
else
|
|
|
|
|
Panel_end_drag(self)
|
|
|
|
@ -680,22 +679,20 @@ function EditField:onInput(keys)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if keys.SELECT then
|
|
|
|
|
if self.key then
|
|
|
|
|
self:setFocus(false)
|
|
|
|
|
end
|
|
|
|
|
if self.on_submit then
|
|
|
|
|
self.on_submit(self.text)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return not not self.key
|
|
|
|
|
elseif keys.SEC_SELECT then
|
|
|
|
|
if keys.SELECT or keys.CUSTOM_SHIFT_ENTER then
|
|
|
|
|
if self.key then
|
|
|
|
|
self:setFocus(false)
|
|
|
|
|
end
|
|
|
|
|
if self.on_submit2 then
|
|
|
|
|
self.on_submit2(self.text)
|
|
|
|
|
return true
|
|
|
|
|
if keys.CUSTOM_SHIFT_ENTER then
|
|
|
|
|
if self.on_submit2 then
|
|
|
|
|
self.on_submit2(self.text)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if self.on_submit then
|
|
|
|
|
self.on_submit(self.text)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return not not self.key
|
|
|
|
|
elseif keys._MOUSE_L then
|
|
|
|
@ -726,25 +723,25 @@ function EditField:onInput(keys)
|
|
|
|
|
self.on_change(self.text, old)
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CURSOR_LEFT then
|
|
|
|
|
elseif keys.KEYBOARD_CURSOR_LEFT then
|
|
|
|
|
self:setCursor(self.cursor - 1)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.A_MOVE_W_DOWN then -- Ctrl-Left (end of prev word)
|
|
|
|
|
elseif keys.CUSTOM_CTRL_B then -- back one word
|
|
|
|
|
local _, prev_word_end = self.text:sub(1, self.cursor-1):
|
|
|
|
|
find('.*[%w_%-][^%w_%-]')
|
|
|
|
|
find('.*[%w_%-][^%w_%-]')
|
|
|
|
|
self:setCursor(prev_word_end or 1)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.A_CARE_MOVE_W then -- Alt-Left (home)
|
|
|
|
|
elseif keys.CUSTOM_CTRL_A then -- home
|
|
|
|
|
self:setCursor(1)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CURSOR_RIGHT then
|
|
|
|
|
elseif keys.KEYBOARD_CURSOR_RIGHT then
|
|
|
|
|
self:setCursor(self.cursor + 1)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.A_MOVE_E_DOWN then -- Ctrl-Right (beginning of next word)
|
|
|
|
|
elseif keys.CUSTOM_CTRL_F then -- forward one word
|
|
|
|
|
local _,next_word_start = self.text:find('[^%w_%-][%w_%-]', self.cursor)
|
|
|
|
|
self:setCursor(next_word_start)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.A_CARE_MOVE_E then -- Alt-Right (end)
|
|
|
|
|
elseif keys.CUSTOM_CTRL_E then -- end
|
|
|
|
|
self:setCursor()
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
@ -938,10 +935,26 @@ function Scrollbar:onRenderBody(dc)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Scrollbar:onInput(keys)
|
|
|
|
|
if not keys._MOUSE_L_DOWN or not self.on_scroll
|
|
|
|
|
or not scrollbar_is_visible(self) then
|
|
|
|
|
if not self.on_scroll or not scrollbar_is_visible(self) then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if self.parent_view:getMousePos() then
|
|
|
|
|
if keys.CONTEXT_SCROLL_UP then
|
|
|
|
|
self.on_scroll('up_small')
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CONTEXT_SCROLL_DOWN then
|
|
|
|
|
self.on_scroll('down_small')
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CONTEXT_SCROLL_PAGEUP then
|
|
|
|
|
self.on_scroll('up_large')
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CONTEXT_SCROLL_PAGEDOWN then
|
|
|
|
|
self.on_scroll('down_large')
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if not keys._MOUSE_L_DOWN then return false end
|
|
|
|
|
local _,y = self:getMousePos()
|
|
|
|
|
if not y then return false end
|
|
|
|
|
local scroll_spec = nil
|
|
|
|
@ -1683,12 +1696,14 @@ end
|
|
|
|
|
function List:submit()
|
|
|
|
|
if self.on_submit and #self.choices > 0 then
|
|
|
|
|
self.on_submit(self:getSelected())
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function List:submit2()
|
|
|
|
|
if self.on_submit2 and #self.choices > 0 then
|
|
|
|
|
self.on_submit2(self:getSelected())
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -1696,12 +1711,10 @@ function List:onInput(keys)
|
|
|
|
|
if self:inputToSubviews(keys) then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if self.on_submit and keys.SELECT then
|
|
|
|
|
self:submit()
|
|
|
|
|
return true
|
|
|
|
|
elseif self.on_submit2 and keys.SEC_SELECT then
|
|
|
|
|
self:submit2()
|
|
|
|
|
return true
|
|
|
|
|
if keys.SELECT then
|
|
|
|
|
return self:submit()
|
|
|
|
|
elseif keys.CUSTOM_SHIFT_ENTER then
|
|
|
|
|
return self:submit2()
|
|
|
|
|
elseif keys._MOUSE_L_DOWN then
|
|
|
|
|
local idx = self:getIdxUnderMouse()
|
|
|
|
|
if idx then
|
|
|
|
|