473,789 Members | 3,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

indentination with tab-key in textarea

Hi,

I want to be able to select 3 rows of a textarea, and when pressing
"Tab/shift Tab" indent the source code edited. Can I do this with
JavaScript?
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%c gl%ssic%ccom%c" , "ma", 58, 'g', 64, "ba", 46, 10);}
Mar 14 '06 #1
1 2395

Gernot Frisch wrote:
[snip]
I want to be able to select 3 rows of a textarea, and when pressing
"Tab/shift Tab" indent the source code edited. Can I do this with
JavaScript?

[/snip]

You can, but it would require a bit of work. Further pointers for
research are:-

1. Event handling. You will need to set "onkeypress " (or perhaps
"onkeydown"/"onkeyup") event handlers on the TEXTAREA element to
capture key presses and trigger your JavaScript function.

2. Event object. You will need to research the browser event
object, how it is delivered to/available to a function, and the keyCode
and shiftKey properties, to enable you to detect which keys were
pressed.

3. You will need to override the normal effect of the TAB key event,
as a TAB normally changes focus (Look for IE event.returnVal ue, Firefox
event.preventDe fault()).

4. You will need to research the browser selection model. Each
browser seems to have its own way of handling text selections. For IE
you need to research the "selection" and "TextRange" objects. For
Mozilla and Safari/KHTML - the selectionStart and selectionEnd
properties of the TEXTAREA element. For others, I do not know. I
think Opera is limited in this respect.

5. You will need to write a function to extract the text from the
selection, manipulate the string to add remove tabs, and paste the text
back into the selection.

Of couse, someone alse may have a working script for all of this.

Regards

Julian Turner

Mar 14 '06 #2

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

Similar topics

147
7788
by: Sateesh | last post by:
Hi, I am a beginner in Python, and am wondering what is it about the indentation in Python, without which python scripts do not work properly. Why can't the indentation not so strict so as to give better freedom to the user? Is there any plausible reason behind this? Cheers! Sateesh
5
27550
by: Paul Mendez | last post by:
I am creating a form with a tab control containing 10 tabs. and what I want to do is on only on of the tabs, I want a sub section of tabs. So what it ends up being is one main tab control with another tab control embedded into only one of the tab pages. The problem I am getting is when I insert the sub section tab control into one of the tabs from the main tab control, the sub section tab control appears in every tab in the main tab...
9
7976
by: Lance Johnson | last post by:
I would like for when a tab page changes, that my controls on the previous tab page would receive a visiblechanged event or some other event so they are aware of that. We have db locks in some of our controls when they're visible and so if a tab page is changed, I would like for the control to know it's no longer visible and release that lock. Currently that doesn't happen. Does anybody have any suggestions and/or is this a bug? Lance...
2
2404
by: Johann Blake | last post by:
The following is a bug I have discovered using tab pages and threads and I am looking for a workaround. Create a new Windows Forms application and add a tab control with two tab pages. Add a label to each tab page. On the first tab page add a button. When the button is pressed the code behind the button creates a thread and starts that thread. The only thing that the thread is to do is to switch from the first tab page to the 2nd tab...
13
3908
by: KMiller | last post by:
I would like to control entry into one or more of the tabs > I have set up on my Tab control based on set rules. Does > anyone know how to grey-out the text so that a user will > see that they do not have access to that particular tab? > > I tried setting the enabled = false for the given tab, but > it only seems to work in the form assembly section (that > is, if I do it after the form is loaded through a > function, it doesn't seem...
11
3228
by: Dave | last post by:
Access 2003 I have a main form with two tab forms, one showing Client, and the other Spouse info, each with Address tabs. When I click on the Client address tab, I would like to have the Spouses address tab show as well. Although the above is the primary issue to resolve, it would also be handy to go a step further...each Address tab has a sub-form with two tabs; Civic Address, and Mailing Address. Being able to click on the Clients...
6
2003
by: DrifterKona | last post by:
I have a form with 4 pages. I'm not sure of the correct name, but I will refer to the tabs at the top of the form that list the names of the four pages as the "page tabs". When the form opens, the body of the form automatically scrolls down to the first tab stop on the form. This causes the body of the form to scroll down so far that the page tabs are no longer viewable. That is undesirable for two reasons. First, if a user wants to...
7
2213
daJunkCollector
by: daJunkCollector | last post by:
The following code creates some very nice tabs. However, the I click the tab it displays specified text below the button. I want the tab to execute a page change, so I can use the tabs for my page's primary navigation. Is there a simple change I can make so that click the tab causes the current URL to change? Thanks <script language="JavaScript">
1
5806
by: chaitanyadotcom | last post by:
As per my application i need to create tabs using iFrame dynamically. There are totally 4 buttons in my application where for each button i provide a link. Where in it will dynamically create a tab inside the iFrame. For example.. first button contains google.com second button contains yahoo.com 3rd button contains hotmail.com if i click on first button i.e google.com , tab is created and link to google.com is generated as a tab in...
2
3052
by: San24 | last post by:
Guys, Let me explain the application I have - Form > Main Tab Control > Main Tab Page > User Control > Sub Tab Control > Sub Tab Page > User Control > Contols/Text Box. Form - The main form Main Tab Control - This contains Main Tab Pages.
0
10408
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, 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...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
agi2029
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...
1
7529
isladogs
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...
0
6768
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();...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
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...

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.