Formspec for multi-line text

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Formspec for multi-line text

by Wuzzy » Thu Sep 25, 2014 05:12

It would be useful if Minetest supports a formspec element to show a text box.

The properties I wish are:
  • Read only
  • Looks like a label, only with multiple lines
  • Lua scripter specifies position, size and text of the textbox. Line breaks happen automatically at the end of the textbox, like for textareas.
  • Optional: A scrollbar for the whole textarea if the text is too long (like for textlists).
  • I don’t care about background. That could be added with the box element anyways, so I don’t see a need for it.


All current solutions I can imagine for multi-line text are ugly work arounds:
  • Create text from textlist. Downside: You must manually place line breaks as “,”. This in turn forces you to escape manually, because you can’t throw the text into minetest.formspec_escape, because those commas would be escaped, too!
  • Textarea. Downside: This is an input field which can be edited.
  • Manually placing labels line per line. Way too much work.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Formspec for multi-line text

by Sokomine » Fri Sep 26, 2014 00:07

Such a formspec element would be great! There had been multiple instances where I had to patch together information texts from labels or use textareas, although those don't look particulary fine. It's a pain to get a decently formatted message that's longer than two or three words at the player.
A list of my mods can be found here.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: Formspec for multi-line text

by 4aiman » Fri Sep 26, 2014 07:39

Do want too!
For now it can be done with tables:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]
^ show scrollable table using options defined by the previous tableoptions[]
^ displays cells as defined by the previous tablecolumns[]
^ x and y position the itemlist relative to the top left of the menu
^ w and h are the size of the itemlist
^ name fieldname sent to server on row select or doubleclick
^ cell 1...n cell contents given in row-major order
^ selected idx: index of row to be selected within table (first row = 1)
^ see also minetest.explode_table_event (main menu: engine.explode_table_event)

tableoptions[<opt 1>;<opt 2>;...]
^ sets options for table[]:
^ color=#RRGGBB
^^ default text color (HEX-Color), defaults to #FFFFFF
^ background=#RRGGBB
^^ table background color (HEX-Color), defaults to #000000
^ border=<true/false>
^^ should the table be drawn with a border? (default true)
^ highlight=#RRGGBB
^^ highlight background color (HEX-Color), defaults to #466432
^ highlight_text=#RRGGBB
^^ highlight text color (HEX-Color), defaults to #FFFFFF
^ opendepth=<value>
^^ all subtrees up to depth < value are open (default value = 0)
^^ only useful when there is a column of type "tree"
 

User avatar
jp
Member
 
Posts: 705
Joined: Wed Dec 18, 2013 09:03
GitHub: kilbith

Re: Formspec for multi-line text

by jp » Fri Sep 26, 2014 08:32

EDIT: nvm.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Formspec for multi-line text

by Krock » Fri Sep 26, 2014 18:36

Yes please. A scrollbar is missing on the textarea and the textlist is just unfriendly for that.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

It's possible?!?!?!

by Wuzzy » Wed Mar 04, 2015 09:07

OMG!
While I was adding tooltips for the main menu, I figured out that textarea can be made read-only and looking like a multi-line label by leaving the “name” and “default” arguments empty and using the “label” as text.

Example formspec code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
textlist[1,1;6,3;;Your text goes here;]


Nothing of this is mentioned in lua_api.txt. Grrrrrrrrrrrrrrrrrr!

However, it is not perfect; it still lacks a scroll bar.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 25 guests

cron