Make it select the first index at the new page when scrolling with the mouse in an horizontal orientaiton
This commit is contained in:
parent
436b8eb241
commit
92b651b4c7
|
@ -42,7 +42,7 @@ local function has_value(tab, val)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function scroll(self, dir)
|
local function scroll(self, dir, page_dir)
|
||||||
local grid = self:get_grid()
|
local grid = self:get_grid()
|
||||||
if #grid.children < 1 then
|
if #grid.children < 1 then
|
||||||
self._private.selected_app_widget = nil
|
self._private.selected_app_widget = nil
|
||||||
|
@ -50,7 +50,6 @@ local function scroll(self, dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
local next_app_index = nil
|
local next_app_index = nil
|
||||||
local if_cant_scroll_func = nil
|
|
||||||
local grid_orientation = grid:get_orientation()
|
local grid_orientation = grid:get_orientation()
|
||||||
|
|
||||||
if dir == "up" then
|
if dir == "up" then
|
||||||
|
@ -59,28 +58,24 @@ local function scroll(self, dir)
|
||||||
elseif grid_orientation == "vertical" then
|
elseif grid_orientation == "vertical" then
|
||||||
next_app_index = grid:index(self:get_selected_app_widget()) - grid.forced_num_cols
|
next_app_index = grid:index(self:get_selected_app_widget()) - grid.forced_num_cols
|
||||||
end
|
end
|
||||||
if_cant_scroll_func = function() self:page_backward("up") end
|
|
||||||
elseif dir == "down" then
|
elseif dir == "down" then
|
||||||
if grid_orientation == "horizontal" then
|
if grid_orientation == "horizontal" then
|
||||||
next_app_index = grid:index(self:get_selected_app_widget()) + 1
|
next_app_index = grid:index(self:get_selected_app_widget()) + 1
|
||||||
elseif grid_orientation == "vertical" then
|
elseif grid_orientation == "vertical" then
|
||||||
next_app_index = grid:index(self:get_selected_app_widget()) + grid.forced_num_cols
|
next_app_index = grid:index(self:get_selected_app_widget()) + grid.forced_num_cols
|
||||||
end
|
end
|
||||||
if_cant_scroll_func = function() self:page_forward("down") end
|
|
||||||
elseif dir == "left" then
|
elseif dir == "left" then
|
||||||
if grid_orientation == "horizontal" then
|
if grid_orientation == "horizontal" then
|
||||||
next_app_index = grid:index(self:get_selected_app_widget()) - grid.forced_num_rows
|
next_app_index = grid:index(self:get_selected_app_widget()) - grid.forced_num_rows
|
||||||
elseif grid_orientation == "vertical" then
|
elseif grid_orientation == "vertical" then
|
||||||
next_app_index = grid:index(self:get_selected_app_widget()) - 1
|
next_app_index = grid:index(self:get_selected_app_widget()) - 1
|
||||||
end
|
end
|
||||||
if_cant_scroll_func = function() self:page_backward("left") end
|
|
||||||
elseif dir == "right" then
|
elseif dir == "right" then
|
||||||
if grid_orientation == "horizontal" then
|
if grid_orientation == "horizontal" then
|
||||||
next_app_index = grid:index(self:get_selected_app_widget()) + grid.forced_num_rows
|
next_app_index = grid:index(self:get_selected_app_widget()) + grid.forced_num_rows
|
||||||
elseif grid_orientation == "vertical" then
|
elseif grid_orientation == "vertical" then
|
||||||
next_app_index = grid:index(self:get_selected_app_widget()) + 1
|
next_app_index = grid:index(self:get_selected_app_widget()) + 1
|
||||||
end
|
end
|
||||||
if_cant_scroll_func = function() self:page_forward("right") end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local next_app = grid.children[next_app_index]
|
local next_app = grid.children[next_app_index]
|
||||||
|
@ -88,7 +83,11 @@ local function scroll(self, dir)
|
||||||
next_app:select()
|
next_app:select()
|
||||||
self:emit_signal("scroll", dir)
|
self:emit_signal("scroll", dir)
|
||||||
else
|
else
|
||||||
if_cant_scroll_func()
|
if dir == "up" or dir == "left" then
|
||||||
|
self:page_forward(page_dir or dir)
|
||||||
|
elseif dir == "down" or dir == "right" then
|
||||||
|
self:page_forward(page_dir or dir)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -384,13 +383,13 @@ local function build_widget(self)
|
||||||
if self:get_grid():get_orientation() == "horizontal" then
|
if self:get_grid():get_orientation() == "horizontal" then
|
||||||
self:scroll_up()
|
self:scroll_up()
|
||||||
else
|
else
|
||||||
self:scroll_left()
|
self:scroll_left("up")
|
||||||
end
|
end
|
||||||
elseif button == 5 then
|
elseif button == 5 then
|
||||||
if self:get_grid():get_orientation() == "horizontal" then
|
if self:get_grid():get_orientation() == "horizontal" then
|
||||||
self:scroll_down()
|
self:scroll_down()
|
||||||
else
|
else
|
||||||
self:scroll_right()
|
self:scroll_right("down")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -538,20 +537,20 @@ function app_launcher:search()
|
||||||
self:emit_signal("search", self:get_text(), self:get_current_page(), self:get_pages_count())
|
self:emit_signal("search", self:get_text(), self:get_current_page(), self:get_pages_count())
|
||||||
end
|
end
|
||||||
|
|
||||||
function app_launcher:scroll_up()
|
function app_launcher:scroll_up(page_dir)
|
||||||
scroll(self, "up")
|
scroll(self, "up", page_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
function app_launcher:scroll_down()
|
function app_launcher:scroll_down(page_dir)
|
||||||
scroll(self, "down")
|
scroll(self, "down", page_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
function app_launcher:scroll_left()
|
function app_launcher:scroll_left(page_dir)
|
||||||
scroll(self, "left")
|
scroll(self, "left", page_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
function app_launcher:scroll_right()
|
function app_launcher:scroll_right(page_dir)
|
||||||
scroll(self, "right")
|
scroll(self, "right", page_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
function app_launcher:page_forward(dir)
|
function app_launcher:page_forward(dir)
|
||||||
|
|
Loading…
Reference in New Issue