Merge template-live-editor-mobile

This commit is contained in:
Kartik K. Agaram 2023-11-19 12:07:16 -08:00
commit 9f21230005
2 changed files with 15 additions and 4 deletions

10
app.lua
View File

@ -68,7 +68,15 @@ function love.run()
App.fake_mouse_press = nil
App.fake_mouse_release = nil
-- other methods dispatch to real hardware
App.screen.resize = love.window.setMode
App.screen.resize = function(width, height, flags)
love.window.setMode(width, height, flags)
if OS == 'iOS' then
love.keyboard.setTextInput(true) -- magic. iOS seems to lose textinput events after calls to setMode.
-- https://github.com/love2d/love/issues/1959
end
end
App.screen.size = love.window.getMode
App.screen.move = love.window.setPosition
App.screen.position = love.window.getPosition

View File

@ -1,6 +1,8 @@
utf8 = require 'utf8'
json = require 'json'
OS = love.system.getOS()
require 'app'
require 'test'
require 'live'
@ -8,8 +10,6 @@ require 'live'
require 'keychord'
require 'button'
OS = love.system.getOS()
-- delegate most business logic to a layer that can be reused by other projects
require 'edit'
Editor_state = {}
@ -218,7 +218,10 @@ function App.keychord_press(chord, key)
end
return
end
love.keyboard.setTextInput(true) -- magic. keeps iOS from losing textinput events after switching apps.
if OS == 'iOS' then
love.keyboard.setTextInput(true) -- magic. iOS is prone to losing textinput events.
-- https://github.com/love2d/love/issues/1959
end
-- ignore events for some time after window in focus (mostly alt-tab)
if Current_time < Last_focus_time + 0.01 then
return