Jump to content




Label wrap for touchpoint API.


  • You cannot reply to this topic
6 replies to this topic

#1 the_dmx

  • Members
  • 3 posts

Posted 22 September 2013 - 01:17 PM

Im just learning Lua. And wondering how I can get label text to wrap to the next line inside of the button instead of trimmed?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 22 September 2013 - 01:26 PM

Split into new topic.

Well, that is a good question. I'll look at the code real quick and see if it'll be a tremendous pain to change that.

What are you looking to have the button say, out of curiousity?

#3 the_dmx

  • Members
  • 3 posts

Posted 22 September 2013 - 01:41 PM

I'm writing a mystcraftportal controller.

example:
pg1:add("The_dmx House", b1_1, 1, 5, 7, 9, colors.red, colors.lime)

The_dmx House gets cut off.

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 29 September 2013 - 04:26 PM

I've added a new optional way to specify button labels. Instead of passing a string, you can pass a table if you need further control of the button label. You could specify your button this way instead, to take advantage of this new option:

pg1:add({"	   ","	   ","The_dmx"," House ","	   ",label = "The_dmx House"}, b1_1, 1, 5, 7, 9, colors.red, colors.lime)

Note that you have to fully specify the characters for every line of the label, including spaces, so this is an option for advanced use. You can also separate out the table to make it easier to read, of course, like so:

local houseLabel = {
    "	   ",
    "	   ",
    "The_dmx",
    " House ",
    "	   ",
    label = "The_dmx House"
}

pg1:add(houseLabel, b1_1, 1, 5, 7, 9, colors.red, colors.lime)


#5 jay5476

  • Members
  • 289 posts

Posted 29 September 2013 - 07:10 PM

lyqyd why not do it like term.write does and cut off at whitespaces if to big but that may be

View PostLyqyd, on 22 September 2013 - 01:26 PM, said:

I'll look at the code real quick and see if it'll be a tremendous pain to change that.


#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 29 September 2013 - 07:32 PM

Because I think that providing these two options is a good balance between simplicity and power. A user providing just a string gets that string, as much as will fit in one line, centered in the button. A user needing more control over it provides a table of each line of the button. Trying to take the textual label and word-wrap it would quickly get rather nasty, and I'm just not interested in getting that much bloat into the touchpoint API.

#7 the_dmx

  • Members
  • 3 posts

Posted 02 October 2013 - 01:07 AM

wow awesome! thank you much for the time you put into this Lyqyd! I'll give this a go asap.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users