diff --git a/docs/changelog.txt b/docs/changelog.txt index 4eb816c29..ca83717ce 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -44,6 +44,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## API ## Lua +- ``widgets.Label``: token ``tile`` properties can now be functions that return a value ## Removed diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 7ead7e374..0c91ece19 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -4704,8 +4704,8 @@ containing newlines, or a table with the following possible fields: * ``token.tile = pen`` - Specifies a pen or texture index to paint as one tile before the main part of - the token. + Specifies a pen or texture index (or a function that returns a pen or texture + index) to paint as one tile before the main part of the token. * ``token.width = ...`` diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index 3ef27a651..46b047254 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -1124,8 +1124,8 @@ function render_text(obj,dc,x0,y0,pen,dpen,disabled,hpen,hovered) if token.tile then x = x + 1 if dc then - local tile_pen = tonumber(token.tile) and - to_pen{tile=token.tile} or token.tile + local tile = getval(token.tile) + local tile_pen = tonumber(tile) and to_pen{tile=tile} or tile dc:char(nil, tile_pen) if token.width then dc:advance(token.width-1)