I am writing a Web-based text editor that will be used mainly for
editing code. To facilitate this task, whenever the Enter button is
pressed within the textarea, the event is caught and the next line is
automatically tabbed to match the previous line. However, because I
have caught the event and manually inserted the line feed along with
the appropriate number of tabs, the textarea doesn't scroll
automatically if the line feed puts the cursor below the last line
visible on the textarea.
Is there any way to force the cursor to remain visible in this
situation?
Chris Finke 4 3542
Christopher Finke wrote: I am writing a Web-based text editor that will be used mainly for editing code. To facilitate this task, whenever the Enter button is pressed within the textarea, the event is caught and the next line is automatically tabbed to match the previous line. However, because I have caught the event and manually inserted the line feed along with the appropriate number of tabs, the textarea doesn't scroll automatically if the line feed puts the cursor below the last line visible on the textarea.
Is there any way to force the cursor to remain visible in this situation?
Use scrollTop (non-standard, DOM 0, but widely supported), something like:
taRef.scrollTop && taRef.scrollTop += 16;
--
Rob
RobG wrote: Christopher Finke wrote:
I am writing a Web-based text editor that will be used mainly for editing code. To facilitate this task, whenever the Enter button is pressed within the textarea, the event is caught and the next line is automatically tabbed to match the previous line. However, because I have caught the event and manually inserted the line feed along with the appropriate number of tabs, the textarea doesn't scroll automatically if the line feed puts the cursor below the last line visible on the textarea.
Is there any way to force the cursor to remain visible in this situation?
Use scrollTop (non-standard, DOM 0, but widely supported), something like:
taRef.scrollTop && taRef.scrollTop += 16;
Ooops, that's crap, eh? Added the 'taRef.scrollTo p && ' quickly before
posting. Try:
('number' == typeof x.scrollTop) && (x.scrollTop += 16);
--
Rob
> Try: ('number' == typeof x.scrollTop) && (x.scrollTop += 16);
I had thought of this, but this will scroll the textarea whether or not
it would have scrolled in the first place. If I use this method, I'd
need a way to determine if the cursor is currently visible in the
textarea. Also, wouldn't the 16 only apply for a certain font size?
Chris
Christopher Finke wrote: Try: ('number' == typeof x.scrollTop) && (x.scrollTop += 16);
I had thought of this, but this will scroll the textarea whether or not it would have scrolled in the first place.
Yes.
If I use this method, I'd need a way to determine if the cursor is currently visible in the textarea.
Yes, as far as I know a textarea doesn't provide anything that will let
you know that. I can think of a number of ways to do it, but they all
are really hackish. If this is for code, why not copy the text into a
text editor (see below)?
Also, wouldn't the 16 only apply for a certain font size?
Yes. scrollTop is in pixels, so that's all you have. Have you
considered using some element other than a textarea? Unfortunately I
think all the alternatives are browser-specific.
Mozilla: designMode
<URL:http://developer.mozil la.org/en/docs/Rich-Text_Editing_in _Mozilla>
IE: contentEditable
<URL:http://msdn.microsoft. com/workshop/author/dhtml/reference/properties/contenteditable .asp>
mozex: edit textarea content in your choice of text editor:
<URL:http://mozex.mozdev.or g/>
There's some helpful stuff here:
<URL:http://ifindkarma.type pad.com/relax/2005/01/life_in_a_texta .html>
Go nuts... :-)
--
Rob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: GAS |
last post by:
I have tried to figure this out for a couple of days now and I'm not
making much headway. I have a cursor that I can't get to work
properly. There are two cursors in the stored procedure. The first
accesses data in the current database and works fine. The second
accesses data in another database on the same server. Whenever I
fetch rows into the second cursor (other database) the variables I
fetch into remain NULL.
I have included...
|
by: Pekka Jarvela |
last post by:
How can I hide the cursor in C++?
I am using Visual Studio .NET and the problem is that the cursor
remains blinking on the opening screen on my program. How can I set it
to be black so that it wouldn't apperar?
Pekka
|
by: Craig |
last post by:
I'm trying to do this within a control I've created:
Cursor.Current = Cursors.WaitCursor;
During the initialization of the parent form, my control gets added to the
form, and while the control is being intialized, I call a method within the
control that sets the cursor to Cursors.WaitCursor, then processing
continues. I want the Cursor to remain that way until I set it back at any
given time, and if I don't set it back, I want to...
|
by: Tibor Odehnal |
last post by:
Hello,
i have a crazy bug on one Machine.
My Application is running fine on 6 Workstations (XP an W2K)
On a new one (XP) i will have a black box as cursor if i want to resize a
listview (instead of east/west-cursor)
plus
|
by: Marc Robitaille |
last post by:
Hello
I build a usercontrol. On this new control, I added two controls, a TextBox
and a ComboBox. My ComboBox is filled with a DataTable. When the user types
something in the TextBox, I apply a filter to the DataView of the DataTable
of my ComboBox. If there is more than one element, I dropdown the list. If I
have one element, it is automatically selected. My problem is that the
cursor works badly. When I type for the first time in...
| |
by: (PeteCresswell) |
last post by:
I've got a screen that has a subform containing an indeterminate number of
records.
When the user clicks "Change", I put the screen into Edit mode by unlocking all
the subform's fields, setting the subform's.AllowEdits = True, .AllowDeletions =
True, and .AllowAdditions = True.
At this point, all the records are showing plus that empty record that becomes
visible when .AllowAdditions=True.
|
by: Paul M |
last post by:
Hi All,
I've been tasked with writing a z/OS C program to read and update a table
(DB/2 v8). This Table contains a single row with a single column of data.
This program (which will run as a Stored Proc) needs to implement a strategy
for concurrency as the Stored Proc can be called concurrently by several
different users.
The code essentially does the following:
|
by: johnlichtenstein |
last post by:
I am using cx_Oracle and MySQLdb to pull a lot of data from some tables
and I find that the cursor.execute method uses a lot of memory that
never gets garbage collected. Using fetchmany instead of fetchall does
not seem to make any difference, since it's the execute that uses
memory. Breaking the query down to build lots of small tables doesn't
help, since execute doesn't give its memory back, after reading enough
small tables execute...
|
by: WALDO |
last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20
lines of text per second. I use the AppendText() method to accomplish this.
This is a great substitute for taking the Text property and concatenating
it...
Me.tb.Text &= newText
' Instead use
Me.tb.AppendText(newText)
....ultimately setting the SelectionStart to the end of TextBox, the
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |