Author Topic: GuiScrollCtrl::scrollToBottom won't scroll to the bottom unless on console  (Read 1198 times)

BLTGuiScroll.scrollToBottom(); only works when entered through console.

Victimized code:
Code: [Select]
function BLT_PushLine(%line)
{
txtBLTGui.addText(" <color:" @ $Pref::BLT::FontColor @ "><font:" @ $Pref::BLT::FontName @ ":" @ $Pref::BLT::FontSize @ ">" @ %line @ "<br>",1);
BLTGuiScroll.scrollToBottom();
}


function BLT_PushError(%line,%error)
{
%errorpre = " <color:" @ $Pref::BLT::FontColorError @ "><font:" @ $Pref::BLT::FontNameError @ ":" @ $Pref::BLT::FontSize @ ">ERROR: ";

//- ERROR SCHEMES
//-- 0: No information available or custom error
//-- 1: Command not found
//-- 2: Server timed out
//-- 3: Server cancelled timeout without a timeout process running
switch(%error)
{
case 0:
txtBLTGui.addText(%errorpre @  %line @ "<br>",1);
case 1:
txtBLTGui.addText(%errorpre @  "Command not found: " @ %line @ "<br>",1);
case 2:
txtBLTGui.addText(%errorpre @  "Server timed out for command: " @ %line @ "<br>",1);
case 3:
txtBLTGui.addText(%errorpre @  "Server tried to stop timeout, but the timeout event wasn't present<br>",1);
default:
txtBLTGui.addText(%errorpre @  "Unknown Error (" @ %error @ "): " @ %line @ "<br>",1);
}
BLTGuiScroll.scrollToBottom();
}

Victimized GUI:
Code: [Select]
//--- OBJECT WRITE BEGIN ---
new GuiControl(BLTGui) {
   profile = "GuiDefaultProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "640 480";
   minExtent = "8 2";
   enabled = "1";
   visible = "1";
   clipToParent = "1";

   new GuiWindowCtrl(BLTGuiWindow) {
      profile = "GuiWindowProfile";
      horizSizing = "center";
      vertSizing = "center";
      position = "68 46";
      extent = "504 387";
      minExtent = "225 125";
      enabled = "1";
      visible = "1";
      clipToParent = "1";
      command = "canvas.popDialog(BLTGui);";
      accelerator = "escape";
      text = "Blockland Event Terminal: [unconnected]";
      maxLength = "255";
      resizeWidth = "0";
      resizeHeight = "0";
      canMove = "1";
      canClose = "1";
      canMinimize = "1";
      canMaximize = "0";
      minSize = "50 50";
      closeCommand = "canvas.popDialog(BLTGui);";
         helpTag = "0";

      new GuiTextEditCtrl(txtBLTGuiEntry) {
         profile = "GuiTextEditProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "4 364";
         extent = "495 18";
         minExtent = "8 2";
         enabled = "1";
         visible = "1";
         clipToParent = "1";
         altCommand = "BLT_DoCmd(txtBLTGuiEntry.getValue());";
         accelerator = "return";
         maxLength = "255";
         historySize = "0";
         password = "0";
         tabComplete = "0";
         sinkAllKeyEvents = "0";
      };
      new GuiScrollCtrl(BLTGuiScroll) {
         profile = "GuiScrollProfile";
         horizSizing = "width";
         vertSizing = "top";
         position = "5 27";
         extent = "494 334";
         minExtent = "0 0";
         enabled = "1";
         visible = "1";
         clipToParent = "1";
         willFirstRespond = "0";
         hScrollBar = "alwaysOn";
         vScrollBar = "alwaysOn";
         constantThumbHeight = "1";
         childMargin = "0 0";
         rowHeight = "40";
         columnWidth = "30";
            resizeHeight = "1";
            helpTag = "0";
            resizeWidth = "1";

         new GuiMLTextCtrl(txtBLTGui) {
            profile = "GuiDefaultProfile";
            horizSizing = "right";
            vertSizing = "bottom";
            position = "1 1";
            extent = "475 379";
            minExtent = "8 2";
            enabled = "1";
            visible = "1";
            clipToParent = "1";
            lineSpacing = "2";
            allowColorChars = "1";
            maxChars = "-1";
            maxBitmapHeight = "-1";
            selectable = "0";
            autoResize = "1";
         };
      };
   };
};
//--- OBJECT WRITE END ---

Please tell me why the GUI won't scroll to the bottom unless the command is entered through console.

http://forum.blockland.us/index.php?topic=193371.msg5202685#msg5202685

I'll try making it a GuiMLScrollCtrl
That doesn't exist, might've been Greek2Me's typo.
« Last Edit: August 18, 2012, 06:38:06 PM by Axolotl »

But the addText in that function is working just fine?


Just for testing purposes, try changing that line to BLTGuiScroll.schedule(1000, scrollToBottom);

It could be an issue with adding the text then scrolling so quickly after. If this works you could probably reduce the schedule to 0 or 1, the 1000 is just so it's obviously delayed and thus you know the line worked.

Just for testing purposes, try changing that line to BLTGuiScroll.schedule(1000, scrollToBottom);

It could be an issue with adding the text then scrolling so quickly after. If this works you could probably reduce the schedule to 0 or 1, the 1000 is just so it's obviously delayed and thus you know the line worked.
100 is a working delay

Also, thank you.

Yeah you need a delay, but even then, it looks stuffty.

Instead use gui.resize();
i think if you resize it so it is on the bottom of the scroll control, it would be exactly like the scrolltobottom function except you can control it better.

If you use .resize(x,y,w,h) on the child and then .schedule(0,"scrolltobottom") on the scroll it should work fine
It just needs a tick to update the child height. There'll still be a tiny flash of the new height before it scrolls.

Also, look into GuiMessageVectorCtrls. You'd have to make a custom profile, set their font face and size on it, and set their font colors in .fontColor[0-9] to style it (and you can't do substyles), but when you push a line on a message vector it automatically scrolls the parent scrollctrl. Stupid hacked in functionality there, but it does work (RTB chats use these, last I checked)

If you use .resize(x,y,w,h) on the child and then .schedule(0,"scrolltobottom") on the scroll it should work fine
It just needs a tick to update the child height. There'll still be a tiny flash of the new height before it scrolls.

Also, look into GuiMessageVectorCtrls. You'd have to make a custom profile, set their font face and size on it, and set their font colors in .fontColor[0-9] to style it (and you can't do substyles), but when you push a line on a message vector it automatically scrolls the parent scrollctrl. Stupid hacked in functionality there, but it does work (RTB chats use these, last I checked)

if you use .resize() with the right math, the scrolltobottom isnt needed at all