-
Notifications
You must be signed in to change notification settings - Fork 0
Widget Methods
widget:echo("Plain text\n") -- Plain text
widget:cecho("<red>Colored</red> text\n") -- Color names
widget:decho("<255,128,0>RGB text\n") -- RGB values
widget:hecho("#FF8000Hex text\n") -- Hex colors
widget:clear() -- Clear contentwidget:dock("left") -- Dock to left sidebar
widget:dock("right") -- Dock to right sidebar
widget:dock("left", 0) -- Dock to specific row (0 = first)
widget:undock() -- Make floating at current position
widget:undock(200, 300) -- Make floating at specific position
widget:isDocked() -- Returns "left", "right", or nilDocking, position, and size methods operate on the widget's group. When a widget is on its own (the usual case) that is just the widget itself; when it has been combined with others, these methods act on the whole group.
widget:show() -- Show the widget
widget:hide() -- Hide the widget
widget:toggle() -- Toggle visibility
widget:isVisible() -- Returns true/falsewidget:setTitle("New Title") -- Change title
widget:setFont("Consolas", 12) -- Set font and size
widget:setBackgroundColor(20, 20, 20) -- Set MiniConsole background (RGB)
widget:setTitleStyleSheet([[ -- Custom title bar style
background-color: rgb(60,60,60);
color: white;
]])
widget:setContentStyleSheet([[ -- Custom content area style
background-color: rgb(20,20,30);
]])
-- Per-widget font size offset from the global content font size
widget:setFontAdjust(2) -- 2pt larger than global
widget:setFontAdjust(-1) -- 1pt smaller than global
widget:setFontAdjust(0) -- Reset to global sizesetBackgroundColor() sets the MiniConsole background color. setContentStyleSheet() sets the background label behind the console (visible in padding areas).
widget:resize(300, 200) -- Resize to width, height
widget:resize(nil, 250) -- Resize height only (pass nil to skip a dimension)
widget:move(100, 100) -- Move (floating only)
widget:raise() -- Bring to front
local x, y = widget:getPosition()
local w, h = widget:getSize()-- Replay buffered echo calls at the current width (called automatically on resize)
widget:reflow()During a live drag the automatic reflow is deferred to the release, because replaying echo buffers per mouse move stutters. A widget that renders from its own state (clear and repaint from the latest data) can bind its renderer as its instance reflow and pass liveReflow = true to the constructor to repaint on every move instead - see Widget Options.
-- Embed the Mudlet mapper
widget:embedMapper()
-- Remove mapper and restore normal content
widget:removeMapper()widget:destroy() -- Remove widget and clean up-- Get a widget by name (returns nil for tabbed widgets)
local widget = mdw.Widget.get("Inventory")
-- Get list of all widget names (both types)
local names = mdw.Widget.list()
-- Show/hide all widgets
mdw.Widget.showAll()
mdw.Widget.hideAll()
-- Get sorted list of all widget names
local allNames = mdw.getWidgetNames()Widget.get() only returns regular widgets; use TabbedWidget.get() for tabbed widgets. Widget.list() returns names of all widget types.
Widgets can be accessed by name from any script using the get() class methods. This allows you to create widgets in one place and push data to them from separate scripts (like GMCP handlers).
-- Get a regular widget
local stats = mdw.Widget.get("Stats")
if stats then
stats:cecho("<green>Updated!\n")
end
-- Get a tabbed widget
local comm = mdw.TabbedWidget.get("Comm")
if comm then
comm:cechoTo("Room", "<white>Hello!\n")
end