Autoscroll text-area for Print

Monkey Targets Forums/HTML5/Autoscroll text-area for Print

therevills(Posted 2011) [#1]
If you are like me and use the Print command as a debugging tool you might like to add this to your monkey lang.js:

game_console.scrollTop = game_console.scrollHeight - game_console.clientHeight;


So the print function now looks like this:

modules/monkey/native/lang.js
function print( str ){
	if( game_console ){
		game_console.value+=str+"\n";
		game_console.scrollTop = game_console.scrollHeight - game_console.clientHeight;

	}
	if( window.console!=undefined ){
		window.console.log( str );
	}
}


Now when your have a lot of debug information, it will auto scroll the text area, so the last print statement is always visable.


degac(Posted 2011) [#2]
Ah! My saviour!
I become mad scrolling manually the textarea to see what the hell happens!
I miss a proper 'debug' file to check-out...

Thank you very much!


Loofadawg(Posted 2011) [#3]
Wonderfully useful. Thanks.


Xaron(Posted 2011) [#4]
Yay thanks! Mark, could you add this officially please? :)


therevills(Posted 2011) [#5]
Another option is you could just put the last print statement at the top of the text area so it doesnt have to scroll down:

function print( str ){
	if( game_console ){
		game_console.value=str+"\n"+game_console.value;
	}
	if( window.console!=undefined ){
		window.console.log( str );
	}
}


But I think reading from top-to-bottom is more natural...


slenkar(Posted 2011) [#6]
thanks

It took me a couple of minutes to find where to put it so Ill put the directory here:
Monkey\modules\monkey\native


therevills(Posted 2011) [#7]
lol - thats in the first post... maybe read the text as well as the code ;)


So the print function now looks like this:

modules/monkey/native/lang.js




DruggedBunny(Posted 2011) [#8]

Yay thanks! Mark, could you add this officially please? :)


Seconded, that's much better now!


marksibly(Posted 2011) [#9]
Hi,

Added!


slenkar(Posted 2011) [#10]
thanks


therevills(Posted 2011) [#11]
Added!


Excellent! :)


Dabz(Posted 2011) [#12]
Cor!!!!

Dabz