]> git.lizzy.rs Git - minetest.git/blobdiff - builtin/mainmenu/tab_local.lua
Fix Enter key after creating a new world (#12997)
[minetest.git] / builtin / mainmenu / tab_local.lua
index 7887039abc1251c4c6c9aa28c5aaf3c6725cd24c..eed373428226611e36882a964bea5a9ab2f82895 100644 (file)
@@ -215,6 +215,10 @@ local function main_button_handler(this, fields, name, tabdata)
 
        assert(name == "local")
 
+       if this.dlg_create_world_closed_at == nil then
+               this.dlg_create_world_closed_at = 0
+       end
+
        local world_doubleclick = false
 
        if fields["sp_worlds"] ~= nil then
@@ -269,6 +273,12 @@ local function main_button_handler(this, fields, name, tabdata)
        end
 
        if fields["play"] ~= nil or world_doubleclick or fields["key_enter"] then
+               local enter_key_duration = core.get_us_time() - this.dlg_create_world_closed_at
+               if world_doubleclick and enter_key_duration <= 200000 then -- 200 ms
+                       this.dlg_create_world_closed_at = 0
+                       return true
+               end
+
                local selected = core.get_textlist_index("sp_worlds")
                gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
 
@@ -316,6 +326,7 @@ local function main_button_handler(this, fields, name, tabdata)
        end
 
        if fields["world_create"] ~= nil then
+               this.dlg_create_world_closed_at = 0
                local create_world_dlg = create_create_world_dlg()
                create_world_dlg:set_parent(this)
                this:hide()