mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 02:17:53 +02:00
commit 698cdba5a469f900b902da360ad05e103cd1a39b Author: Björn Ritzl <bjorn.ritzl@gmail.com> Date: Wed Mar 29 11:10:49 2023 +0200 Documentation commit d8de338a465066a9b9ff1bb6d20b5476e78d6359 Author: Björn Ritzl <bjorn.ritzl@gmail.com> Date: Wed Mar 29 10:40:38 2023 +0200 Added focus and post listener setup functions commit 55910abd74542513795dae3ccb9b4fd87da22b74 Author: Björn Ritzl <bjorn.ritzl@gmail.com> Date: Wed Mar 29 09:49:00 2023 +0200 Update gui.lua commit a055af032fb47d67647e0b7bc09ad4721fd623d7 Author: Björn Ritzl <bjorn.ritzl@gmail.com> Date: Wed Mar 29 09:19:49 2023 +0200 Improve transition setup
35 lines
1.1 KiB
Plaintext
35 lines
1.1 KiB
Plaintext
local monarch = require "monarch.monarch"
|
|
local transitions = require "monarch.transitions.gui"
|
|
|
|
function init(self)
|
|
msg.post(".", "acquire_input_focus")
|
|
|
|
local DURATION = 0.3
|
|
local transition = transitions.create(gui.get_node("bg"))
|
|
.show_in(transitions.slide_in_right, gui.EASING_LINEAR, DURATION, 0)
|
|
.show_out(transitions.slide_out_left, gui.EASING_LINEAR, DURATION, 0)
|
|
.back_in(transitions.slide_in_left, gui.EASING_LINEAR, DURATION, 0)
|
|
.back_out(transitions.slide_out_right, gui.EASING_LINEAR, DURATION, 0)
|
|
|
|
monarch.on_transition("window1", transition)
|
|
|
|
monarch.on_focus_changed("window1", function(message_id, message)
|
|
if message_id == monarch.FOCUS.GAINED then
|
|
print("window1 gained focus")
|
|
elseif message_id == monarch.FOCUS.LOST then
|
|
print("window1 lost focus")
|
|
end
|
|
end)
|
|
end
|
|
|
|
function on_input(self, action_id, action)
|
|
if action_id == hash("touch") and action.released then
|
|
if gui.pick_node(gui.get_node("button"), action.x, action.y) then
|
|
monarch.show("window2")
|
|
end
|
|
end
|
|
end
|
|
|
|
function on_message(self, message_id, message, sender)
|
|
monarch.on_message(message_id, message, sender)
|
|
end |