mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
console.lua: don't convert integers for mp.input to string
I misunderstood CogentRedTester's review in https://github.com/mpv-player/mpv/pull/10282#discussion_r1428972352 as referring to the cursor_position in mp.input's arguments instead of the one received by the closed callback. The cursor_position passed to input.get doesn't need to be converted to a number because it was already JSON, while the cursor_position received by the closed callback is currently a string, and we need to pass JSON in input-event script messages to keep it as an integer to work around mpv converting integer script message arguments to string. This is more noticeable after implementing mp.input.select(): its submit argument currently receives the selected index as a string, and this makes Lua error if you use it as an index of a numerical table, e.g.: submit = function (id) mp.set_property(property, tracks[tonumber(id)].selected and "no" or tracks[tonumber(id)].id) ... end, This commit avoids having to call tonumber(id).
This commit is contained in:
committed by
Kacper Michajłow
parent
994a08f5a7
commit
eb4c6be630
@@ -63,7 +63,8 @@ local mp_globals = {
|
||||
set_mouse_area = {},
|
||||
set_osd_ass = {},
|
||||
}
|
||||
}
|
||||
},
|
||||
unpack = {},
|
||||
}
|
||||
|
||||
local mp_internal = {
|
||||
|
||||
Reference in New Issue
Block a user