PDA

View Full Version : How to update scrollField?


AtrusDni
04-01-2008, 08:46 PM
So i have my script and im outputing different information into a scrollField. Basically im making my own version of the output window. Problem is though that when I insert text into a new line of the scroll field, the scroll bar doesnt update. I would like it to constantly scroll down to reveal the new line that is being spit out, but I cannot find any way to do this. I want it to behave like the output window, but I havent had any luck. Am I going about this wrong? Should I be using a scroll field? Any ideas?

Buexe
04-01-2008, 09:08 PM
Since I don`t know the specific purpose of your control and you say you want to sort of replace the outliner, may I suggest to take a look at the textScrollList control? It has a -showIndexedItem flag, which should give you the behaviour you described. And a sidenote, it is looking at first a little tricky but actually it is not that hard ( okay that`s probably relative ) to implement a custom outliner which shows only the stuff you want. There are some examples in the docs if I recall correctly.
cheers
buexe

AtrusDni
04-02-2008, 02:23 AM
Thanks for the information Buexe, but I dont think the textScrollList works the way that I would like it to. So in my script there is a panel at the bottom that spits out information about whats going on with the script. I could have just used - print ("Whatever blah blah on " + $obj + "\n"); - but problem with that is you have to sift though the script editor to find out what is going on, so I created a scrollField thats part of the script window that displays all the information to the user. It is exactly like the output window, where it just displays information. You can highlight and select the information too in case you need to copy it and save it. The problem is , unlike the output window which constantly refreshes and scrolls down to show the newest line, the scrollField will create a scroll bar correctly, but if the added lines go beyond what it can display, it wont automatically scroll down to show you it. Thats what im looking for a way to do. I hope this is a little more clear.

Buexe
04-02-2008, 07:47 AM
Okay, I got it, it is always good to know the "reason behind the madness" : )
But I`m afraid I can be of no further help then : (
Cheers

sj_bee
04-02-2008, 02:25 PM
if you use a scrollLayout rather than a scrollField you can use the -scrollPage and -scrollByPixel flags to scroll up and down.

I don't know how you would get text to dispaly in a scrollLayout the same way that it dispalys in a scrollField though...

Norb
04-02-2008, 04:43 PM
Or if you felt like it, you could have all the new information be placed at the top of the scroll field (so opposite of the script editor for example) that way, everything new is the top line and always visible.

AtrusDni
04-03-2008, 12:38 AM
Thanks for all your help guys. So this is what I came up with:

global proc scrollTestUI()
{
if (`window -exists scrollTest`)
deleteUI scrollTest;

window -widthHeight 400 200 -t "Scoll Test" -s 0 -tlb 1 scrollTest;

scrollLayout -horizontalScrollBarThickness 16 -verticalScrollBarThickness 16 scrollArea;
columnLayout;
text -l "blah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\n" textArea;
setParent..;
setParent..;

showWindow scrollTest;
}
scrollTestUI();



/*
// Run this code to add more text and scroll to the bottom at the same time:

string $oldText = `text -q -l textArea`;
text -e -l ($oldText + "newblah\n") textArea;
scrollLayout -e -scrollByPixel "down" 100 scrollArea;

*/

sj_bee
04-03-2008, 09:38 AM
looks good

strarup
04-03-2008, 07:44 PM
Hi,

just experimented a bit by using an scrollField... unfortunately it doesn't has the scroll down thingie...
but then again you can have the newest text showed at the top as Norb wrote... :)

e.g. if you use the text thingie in your example by putting in the text in the label...
like newblah... all the other "blah"'s get moved and suddenly all the text isn't alligned...
also it isn't posible to mark/highlight and copy text from it...

btw. made a little proc function to your code example...

proc addDaScrollTestText(string $daText)
{
//Run this code to add more text and scroll to the bottom at the same time:
string $oldText = `text -q -l textArea`;
text -e -l ($oldText + $daText+"\n") textArea;
scrollLayout -e -scrollByPixel "down" 100 scrollArea;
}

e.g. by using the command addDaScrollTestText("newblah");


regarding the scrollField code example I have put in code to put the text at the "top" as Norb suggested...
it is outcommented with /* */ just remove those if you want the new text to be at the top...

there are 2 ways to get text added in this example... in a textField or by using a command e.g. from a script or the commandline...

kind regards

Strarup


proc scrollTestUI()
{
if (`window -exists daScrollTestUI`)
deleteUI daScrollTestUI;

window -widthHeight 330 350 -t "Scroll Test" -s 0 -tlb 1 daScrollTestUI;
//window -widthHeight 330 350 -t "Scroll Test" daScrollTestUI;
formLayout daScrollTestUIFormLayout;
//you can either use the enter key on the numeric keypad to execute the command to add the text to the scrollfield
textField -w 210 -ed true -annotation "type in your text here e.g. use enter on numeric keypad or the button to add this text to the scrollfield..." -ec "updateDaScrollTextArea;" daScrollTxtFld;
//or just press this button... :)
button -label "type your text" -en true -w 80 -annotation "execute the command to add the text to the scrollfield..." -c "updateDaScrollTextArea;" daScrTxtCmdBtn;
separator -width 300 "ScrTest_UiSep01" ;
scrollField -ed 0 -height 200 -width 300 -tx "blah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nbl ah\nblah\nblah\n" -ww 1 daScrollArea;
separator -width 300 "ScrTest_UiSep02" ;
button -label "Clear" -annotation "clear the scrollfield text area..." -w 90 -c "clearDaScrollTextArea;" daScrTestClearCmdBtn;
button -label "Close" -annotation "HUH!!! just closing da UI... :-D" -w 90 -c "deleteUI daScrollTestUI;" daScrTestCloseBtn;
formLayout -e
-af "daScrollTxtFld" "left" 10
-af "daScrollTxtFld" "top" 10
-af "daScrTxtCmdBtn" "left" 230
-af "daScrTxtCmdBtn" "top" 10
-af "ScrTest_UiSep01" "left" 10
-af "ScrTest_UiSep01" "top" 40
-af "daScrollArea" "left" 10
-af "daScrollArea" "top" 55
-af "ScrTest_UiSep02" "left" 10
-af "ScrTest_UiSep02" "top" 270
-af "daScrTestClearCmdBtn" "left" 50
-af "daScrTestClearCmdBtn" "top" 280
-af "daScrTestCloseBtn" "left" 170
-af "daScrTestCloseBtn" "top" 280
daScrollTestUIFormLayout;
showWindow daScrollTestUI;
int $daWinSize[] = `window -q -wh daScrollTestUI`;
if($daWinSize[0] != 330)
{
window -e -w 330 daScrollTestUI;
}
if($daWinSize[0] != 350)
{
window -e -h 350 daScrollTestUI;
}
}
scrollTestUI();

proc clearDaScrollTextArea()
{
//clear the scrollfield...
scrollField -e -cl daScrollArea;
}

proc updateDaScrollTextArea()
{
//this is only to use if you want the new text to be at the top everytime... just remove /* and */
/*
if(`scrollField -q -ip daScrollArea` != 1)
{
scrollField -e -ip 1 daScrollArea;
}
*/
string $daText2Add = `textField -q -tx daScrollTxtFld`;
if($daText2Add != "")
{
$daText2Add = ($daText2Add+"\n");
scrollField -e -it $daText2Add daScrollArea;
textField -e -tx "" daScrollTxtFld;
}
}

//or use this proc to add text from your code to the scrollField...
//e.g. addDaText2DaScrollField("newblah");
proc addDaText2DaScrollField(string $daText)
{
//this is only to use if you want the new text to be at the top everytime... just remove /* and */
/*
if(`scrollField -q -ip daScrollArea` != 1)
{
scrollField -e -ip 1 daScrollArea;
}
*/
if($daText != "")
{
if($daText != "CLEAR")
{
$daText = ($daText+"\n");
scrollField -e -it $daText daScrollArea;
}
else
//using the Text CLEAR will clearing the scrollField
clearDaScrollTextArea;
}
}

CGTalk Moderation
04-03-2008, 07:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.