473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Don't be mad

Please, don't be mad at me for posting another question here..
It's (again) about the carotposition in a textarea, i really have tried to
find a solution through the internet but i haven't succeed in finding the
right one yet.

Enough introduction, I do know exactly what i want. And that is:
I want to know when the carot(cursor) is in the first row of the
textarea(although rows do not really exist, i know) and I want to know when
the cursor is in the last row of the textarea.

Why do I want to know that?
Because when the cursor is in the first row and the keycode for "arrow-up"
event fires, the focus has to leave the textarea and go to the field above
it.
Same goes for the last row, when the arrow-down is pressed it has to go to
the next field.

And when it's in between the first and last line, nothing should happen but
goiing up and down the textarea.

Thanks,
Simon
Jul 17 '07 #1
2 1314
On Jul 17, 9:29 am, "Simon" <simon1...@quicknet.nlwrote:
Please, don't be mad at me for posting another question here..
It's (again) about the carotposition in a textarea, i really have tried to
find a solution through the internet but i haven't succeed in finding the
right one yet.

Enough introduction, I do know exactly what i want. And that is:
I want to know when the carot(cursor) is in the first row of the
textarea(although rows do not really exist, i know) and I want to know when
the cursor is in the last row of the textarea.

Why do I want to know that?
Because when the cursor is in the first row and the keycode for "arrow-up"
event fires, the focus has to leave the textarea and go to the field above
it.
Same goes for the last row, when the arrow-down is pressed it has to go to
the next field.

And when it's in between the first and last line, nothing should happen but
goiing up and down the textarea.

Thanks,
Simon
Hi

Two possibilities occurr to me (both non-trivial).

Firstly, I assume that by "last" row, you are including the fact that
the textarea might overflow the actual visual box and so scroll, and
so you are interested in the very end of the text within the textarea.

Solution 1
----------

One solution might be to test whether the cursor "moved". I.e. if you
are at the top or bottom of the text within the text area, pressing
the up or down arrow will produce no further movement. So you could
capture its previous posiition, compare with the new, and if no
change, "assume" that you are in the first or last row.

Solution 2
----------

The alternative (assuming you are using a fixed-width font) is might
be much more messy, and might require:-

(a) Asertain if you are in the first or last line.

(b) Calculate where the "wrapping" points are in that line (i.e
where does the line wrap to the next row), by looking at the width of
the text area, the number of pixels taken up by each character of
text, for your given font size, and wrapping rules such as wrapping of
whole words.

(c) Look at whether your carot is within those points.

Probably possible, but difficult to code.

Good Luck

Julian Turner



Jul 17 '07 #2
On Jul 17, 9:29 am, "Simon" <simon1...@quicknet.nlwrote:
Please, don't be mad at me for posting another question here..
It's (again) about the carotposition in a textarea, i really have tried to
find a solution through the internet but i haven't succeed in finding the
right one yet.

Enough introduction, I do know exactly what i want. And that is:
I want to know when the carot(cursor) is in the first row of the
textarea(although rows do not really exist, i know) and I want to know when
the cursor is in the last row of the textarea.

Why do I want to know that?
Because when the cursor is in the first row and the keycode for "arrow-up"
event fires, the focus has to leave the textarea and go to the field above
it.
Same goes for the last row, when the arrow-down is pressed it has to go to
the next field.

And when it's in between the first and last line, nothing should happen but
goiing up and down the textarea.

Thanks,
Simon
Hi

Two possibilities occurr to me (both non-trivial).

Firstly, I assume that by "last" row, you are including the fact that
the textarea might overflow the actual visual box and so scroll, and
so you are interested in the very end of the text within the textarea.

Solution 1
----------

One solution might be to test whether the cursor "moved". I.e. if you
are at the top or bottom of the text within the text area, pressing
the up or down arrow will produce no further movement. So you could
capture its previous posiition, compare with the new, and if no
change, "assume" that you are in the first or last row.

Solution 2
----------

The alternative (assuming you are using a fixed-width font) is might
be much more messy, and might require:-

(a) Asertain if you are in the first or last line.

(b) Calculate where the "wrapping" points are in that line (i.e
where does the line wrap to the next row), by looking at the width of
the text area, the number of pixels taken up by each character of
text, for your given font size, and wrapping rules such as wrapping of
whole words.

(c) Look at whether your carot is within those points.

Probably possible, but difficult to code.

Good Luck

Julian Turner

Jul 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
16
by: mike420 | last post by:
Tayss wrote: > > app = wxPySimpleApp() > frame = MainWindow(None, -1, "A window") > frame.Show(True) > app.MainLoop() > Why do you need a macro for that? Why don't you just write
12
by: AFN | last post by:
I am running the code below to generate XML from a data table. But some fields in the data table are Null for every record. Suppose field5 has a null database value. I would expect to see: ...
3
by: Douglas Buchanan | last post by:
Buttons don't work if form is opened on startup A2k If 'frmMain' is set to open by default at startup none of the buttons work. If 'frmMain' is opened from the database window then all the...
28
by: DFS | last post by:
I'm unfortunately about to change, or sever, a two-year relationship with a very slow-paying client. Most of the 15 invoices I've sent them arrive 6 to 8 weeks late, and usually only after...
0
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico...
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
10
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I...
21
by: jehugaleahsa | last post by:
Hello: I had an hour-long discussion with my boss today. Last night, right before I dozed off, I realized some of his code resulted in duplicate processing. I tried to explain it to him and he...
1
Nepomuk
by: Nepomuk | last post by:
You might have heard about Linux, but you don't know what it is? Or you know a few things about it, but they terrify you? Well, then this article is for you. Don't be afraid - Everyone can use Linux!...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.