summaryrefslogtreecommitdiff
path: root/rt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'rt.lua')
-rw-r--r--rt.lua65
1 files changed, 26 insertions, 39 deletions
diff --git a/rt.lua b/rt.lua
index 785a5c7..e937dbc 100644
--- a/rt.lua
+++ b/rt.lua
@@ -951,17 +951,29 @@ function rt.toggle_menu_sort()
osd:dirty()
end
-local function mouse_click_left_menu(dbl, line)
+function rt.click_menu()
+ local line = osd.mstate.option_line
+ if line < 1 then
+ return
+ end
+
+ local menu = state:menu()
+ local pos = menu.view_top + line - 1
+ if pos > #menu.options then
+ return
+ end
+
+ rt.set_cursor(pos)
+end
+
+function rt.dbl_click_menu()
+ local line = osd.mstate.option_line
if line == 0 then
return
end
-- title
if line < 0 then
- if not dbl then
- return
- end
-
if line == -1 then
rt.set_cursor(1)
else
@@ -973,34 +985,23 @@ local function mouse_click_left_menu(dbl, line)
local menu = state:menu()
local pos = menu.view_top + line - 1
- if dbl then
- if pos ~= menu.cursor then
- return
- end
-
- rt.select_option()
- else
- if pos > #menu.options then
- return
- end
-
- rt.set_cursor(pos)
- end
-end
-
-local function mouse_click_left_scrollbar(dbl, ratio)
- if not dbl then
+ if pos ~= menu.cursor then
return
end
+ rt.select_option()
+end
+
+function rt.dbl_click_scrollbar()
-- set_cursor handles out-of-bounds moves (when ratio == 1)
rt.set_cursor(
- math.floor(ratio * #state:menu().options) + 1,
+ math.floor(osd.mstate.ratio * #state:menu().options) + 1,
{centre = true})
end
-local function mouse_click_right_menu(dbl, line)
- if not dbl or line < 1 then
+function rt.dbl_right_click_menu()
+ local line = osd.mstate.option_line
+ if line < 1 then
return
end
@@ -1013,20 +1014,6 @@ local function mouse_click_right_menu(dbl, line)
rt.open_option_info(menu.options[pos])
end
-function rt.mouse_click_left(dbl, area, val)
- if area == 'menu' then
- return mouse_click_left_menu(dbl, val)
- elseif area == 'scrollbar' then
- return mouse_click_left_scrollbar(dbl, val)
- end
-end
-
-function rt.mouse_click_right(dbl, area, val)
- if area == 'menu' then
- return mouse_click_right_menu(dbl, val)
- end
-end
-
function rt.reload_data()
if state.depth > 1 then
osd:flash_error('Can only reload data from root menu')