Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Keyboard 1

Status
Not open for further replies.

Rhys666

Programmer
May 20, 2003
1,106
No sure if anyone's going to have any idea's on this one but here goes.

I'm writing an application that is displayed through NTL/Telewest's Liberate digital interactive tv platform. This is basically an implementation of HTML/ASP/Javascript.

What I'm trying to acheive is to create a 'web' keyboard that displays text (as typed) in a textarea, except I have to manually force the text scrolling.

I've got this implemented and working except for when a line break is entered.

The text area is 3 rows and can display about 27 characters per row. Knowing the maximum displayable characters means I can assess how much text can be displayed before and after my cursor character (the same as in a word processor, displaying where typed text will appear), and I can give the impression of text scrolling as typed. However, when a new line is entered, this throws out the calculations.

Does anyone have any idea's as to how I can calculate for line breaks in my scrolling text?

Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
 

Not knowing what methods the NTL client (sorry - "user agent" ;o) can handle could prove problematic for giving a good solution.

Can you tell us what method you're currently using to scroll the regular text? Also, is there a reference manual online anywhere that shows what methods are available?

For example, IE browsers support the "doScroll" method, but chances of the NTL browser supporting a MS standard are slim, I'd say.

Dan
 
Methods are more than limited, doScroll ain't gonna be there, that I know neither are MS Specific stuff. For ease, think Javascript 1.1 and HTML 3.2

Basically, what Ive got to at the moment is making an assessment of the total length of the text entered and the index position of the cursor in the text. From this I am making an assessment of how much text is displayable both pre and post the cursor in the text field and I'm only displaying a substring of the entered text, which is stored in completeness in a hidden form field. Basically...
Code:
function writeText(txt) 
{
	preCursorTxt = txt.substring(0,cursorPos);
	if (preCursorTxt.length > 80)
	{
		preCursorTxt = '...' + preCursorTxt.substring(preCursorTxt.length-80);
	}
	
	postCursorTxt= txt.substring(cursorPos,txt.length);
	if (postCursorTxt.length + preCursorTxt.length>83)
	{
		postCursorTxt = (postCursorTxt.substring(0, (83-preCursorTxt.length)) + '...');
	}

	outTxt= preCursorTxt + cursor + postCursorTxt;
	document.textField.rows[0].cells[0].write(true, outTxt);
}

Realistically, I think all I'm able to do is try to extend the above, and take into account line breaks. The maximum nuber of lines and characters enterable via the keyboard is defined, and what I'm thining of trying to do is, at the point I'm assessing the preCursorText and postCursorText, calculate the content of each enterable line, (a line being one string of text ending in a line break), and based on this and the position of the cursor calculate what can be displayed on-screen.

Unfortunately taking account of line breaks and cursor position is a pain as our designers put in left and right keys to allow a user to move the cursor within the text string to edit it. So I guess what I'm realistically after are some string manipulation techniques.

Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
 

If you know in advance the number of "cols" you have your textarea set to (which I'm guessing you do), when you hit a CR, can you not add a number of spaces to the displayed string...

The number would be the number of cols minus the current cursor position on that line.

Theoretically, that would work for multiple CRs, too.

Hope this helps,
Dan
 
My apologies, it's just a table not a textarea, as textarea isn't supported by Liberate, which is one of the reasons I have this damned issue.

Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
 
Actually, we've just been discussing that, (it's been a long day!), and we're experimenting at the moment. Of course it helps when you spell things correctly, and don't try to set properties which a textarea doesn't have

Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
 

So we're no clearer now as to what you're using to display your text than when the thread started ;o)

If you don't get any luck with the manual, or here, you could try in the "Cable Systems" forum (forum583) to see if anyone else has experienced issues with Liberate.

Hope this helps,
Dan
 
The code was originally set up to write dynamically to a table cell, as we can get a flashing cursor displayed which we couldn't do in a textarea. We've tried textarea, but just noticed that it's line count is based on \r, but the code was using \n as a newline, so our line count was never going past 1 and scrolling, (which we can theoretically set up to be almost automatic if we can get a non-focusable textarea working).

I'm giving up today, but will try again tomorrow, when hopefully I'll not get so dragged from pillar to post while trying to get this done. Oh well, c'est la vie.

Cheers for the help, have a start for making the effort to find a liberate manual - I'm impressed!

Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top