The project is a widget management module written in Lua. It defines a WidgetManager object that contains methods for managing widgets in LuaRT desktop applications.
The project provides a modular and flexible way to manage widgets in desktop applications. It allows you to add, reorder, hide, show, and change properties of child widgets. Several widget managers can be used in one application.
- Create a folder called "ecluart" in your application.
- Copy the "wm.lua" file into this folder.
[application]
|
|----ecluart
| |
| |----wm.lua
| |----...
|
|----app.wlua
The widget manager (wm) can be loaded using the function require():
local wm = require("ecluart.wm")
WidgetManager() -> object
The code above initializes a new instance of the widget manager object. It returns the newly created object.
WidgetManager:add(widget: object, name: string) -> none
This function adds a widget to the WidgetManager object. It takes an object widget and a string name as parameters. It first checks if the widget is a valid child widget using the isValidChild function. If it is not a valid child widget or the name is not a string, the function returns early. Otherwise, it adds the widget to the children table using the name as the key.
WidgetManager:hide() -> none
This function hides all the child widgets by setting their visible property to false. It iterates over the children table using the each function and sets the visible property of each child widget to false.
WidgetManager:show() -> none
This function shows all the child widgets by setting their visible property to true. It iterates over the children table using the each function and sets the visible property of each child widget to true.
WidgetManager:disable() -> none
This method is responsible for disabling all child widgets. It achieves this by iterating over each child widget and setting its enabled property to false.
WidgetManager:enable() -> none
This method, on the other hand, enables all child widgets. It follows a similar approach as the disable method, but instead sets the enabled property to true.
WidgetManager:change(key: string, value: any) -> none
This function changes a property for all the child widgets. It takes a string key and any value as parameters. It first checks if the key is a string. If it is not, the function returns early. Otherwise, it iterates over the children table using the each function and sets the key property of each child widget to the given value.
WidgetManager:focus(name: string) -> none
This function sets the focus to a specific widget by showing it. It takes a string name as a parameter. It first checks if the name is a string. If it is not, the function returns early. Otherwise, it shows the child widget with the given name by calling the show method on it.
Copyright (c) 2023 by esferatec. It is open source, released under the MIT License. See full copyright notice in the LICENSE.md file.