Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: SizeToFit problem  (Read 4221 times)

0 Members and 1 Guest are viewing this topic.

Prote1n

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 45
    • View Profile
SizeToFit problem
« on: December 02, 2009, 03:00:46 PM »

This function does not take into account the line break

The text "aaa|bbb|ccc|ddd" has the size of "aaabbbccddd" instead of the maximum of the splitted string... but the HeightToFit is well calculted

Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: SizeToFit problem
« Reply #1 on: December 02, 2009, 04:22:19 PM »

How exactly are you using the method? If you're setting the text from script, you should use the "~n" sequence for newlines, not the | character.

SomeControl.Text = "aaa~nbbb~nccc~nddd";
SomeControl.SizeToFit();

...should work, I think...?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Prote1n

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 45
    • View Profile
Re: SizeToFit problem
« Reply #2 on: December 02, 2009, 06:33:53 PM »

I try both (| and ~n) with the same result. I actually solved the problem while splitting the string and calculating the maximum length

       
Logged

Prote1n

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 45
    • View Profile
Re: SizeToFit problem
« Reply #3 on: May 11, 2010, 03:31:40 PM »

Here is my script:

var win=Game.LoadWindow("interface\system\info.window");
var info = win.GetControl("message");

info.Text = "abcdefghijklnmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Width); // RETURNS 236

info.Text = "abcdefghijkl|nmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Width); // RETURNS 248

info.Text = "abcdefghijkl~nnmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Width); // RETURNS 248

Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: SizeToFit problem
« Reply #4 on: May 13, 2010, 09:25:58 PM »

what's info.Height?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Prote1n

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 45
    • View Profile
Re: SizeToFit problem
« Reply #5 on: May 18, 2010, 10:31:11 AM »

var win=Game.LoadWindow("interface\system\info.window");
var info = win.GetControl("message");

info.Text = "abcdefghijklnmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Height); // RETURNS 19

info.Text = "abcdefghijkl|nmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Height); // RETURNS 38

info.Text = "abcdefghijkl~nnmnopqrstuvwxyz";
info.SizeToFit();
Game.LOG (info.Height); // RETURNS 38
Logged
 

Page created in 0.018 seconds with 23 queries.