mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-04-04 15:12:46 +02:00
Переходим на MineOS Standalone #1
This commit is contained in:
46
Applications/Sample.app/Main.lua
Normal file
46
Applications/Sample.app/Main.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
-- Import libraries
|
||||
local GUI = require("GUI")
|
||||
local system = require("system")
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
|
||||
-- Add a new window to MineOS workspace
|
||||
local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 60, 20, 0xE1E1E1))
|
||||
|
||||
-- Get localization table dependent of current system language
|
||||
local localization = system.getCurrentScriptLocalization()
|
||||
|
||||
-- Add single cell layout to window
|
||||
local layout = window:addChild(GUI.layout(1, 1, window.width, window.height, 1, 1))
|
||||
|
||||
-- Add nice grey text object to layout
|
||||
layout:addChild(GUI.text(1, 1, 0x4B4B4B, localization.greeting .. system.getUser()))
|
||||
|
||||
-- Customize MineOS menu for this application
|
||||
local contextMenu = menu:addContextMenu("File")
|
||||
contextMenu:addItem("New")
|
||||
contextMenu:addSeparator()
|
||||
contextMenu:addItem("Open")
|
||||
contextMenu:addItem("Save", true)
|
||||
contextMenu:addItem("Save as")
|
||||
contextMenu:addSeparator()
|
||||
contextMenu:addItem("Close").onTouch = function()
|
||||
window:remove()
|
||||
end
|
||||
|
||||
-- You can also add items without context menu
|
||||
menu:addItem("Example item").onTouch = function()
|
||||
GUI.alert("It works!")
|
||||
end
|
||||
|
||||
-- Create callback function with resizing rules when window changes its' size
|
||||
window.onResize = function(newWidth, newHeight)
|
||||
window.backgroundPanel.width, window.backgroundPanel.height = newWidth, newHeight
|
||||
layout.width, layout.height = newWidth, newHeight
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
|
||||
-- Draw changes on screen after customizing your window
|
||||
workspace:draw()
|
||||
Reference in New Issue
Block a user