Line Numbering Question.

Hi,
Could someone please take a look at the attached screenshot, and point me in the right direction as to how I create the grey vertical bar on the left which displays line numbers.
Does it need to be part of the white TextArea, or does it need to be a separate control?

Thank you all in advance.
Screenshot

Why not use one of the availabe 3rd party edit controls that already have this feature.

I tried this approach years ago and it won’t work (well it can work, just not well)

a) TextArea itself does not support line numbers, so to use a TA the linenumbers would have to be a separate control… Keeping those in synch is a monster

b) most “correct” approaches abandon the TA, and implement the entire thing as a custom control based on a canvas

If you don’t need or want your lines to wrap, you may be able to get away with a ListBox. With enough code, it would look like a text area to a user, and the first cell would hold the number.

Otherwise, I agree with Dave to look into third-party controls.

The CustomEditField does this very neatly and will colour your syntax while it is at it if you need to. https://code.google.com/p/custom-editfield/downloads/list?can=1&q=

Thanks Guys.

Mike,
2 questions:

  1. If I just need the text area with line numbering - what do I need to drag into my own project?

  2. Is it possible to save the text in the text area part to a txt file (in other words - does it act like a text area?)

Thanks.

[quote=90494:@Richard Summers]Thanks Guys.

Mike,
2 questions:

  1. If I just need the text area with line numbering - what do I need to drag into my own project?

  2. Is it possible to save the text in the text area part to a txt file (in other words - does it act like a text area?)

Thanks.[/quote]

Richard,

Drag the customeditfield to your window, in the inspector set ‘Display Line Numbers’ to true and yes you will just refer to your text as CustomEditField1.text.

I think there may be some other obscurities with setting it up I can’t remember right now. Download it and give it a try as above and if you have any issues post here again and I will dig out my code and try and help you.

Thank you so much Mike - I really appreciate your help !!!
I will try that now.

Thanks mate.

Mike,
The only problem I have experienced is that when I set the GutterWidth to 20 for example - the gutter width doesn’t change?
Do I also need to change it elsewhere?

Another small problem was that if I set the Insertion point to thick - it sometimes disappears - but I only want a normal insertion point - so for me - that is not a problem.

Also, can this be used on commercial projects, or do I need to purchase this from somewhere?

Thanks.

If you are using Alex Restrepos Edit Field, you can use it in a commercial application…
However for OSX, it is not Retina ready… so it that might be an issue…then…

I have used it a lot in the past, and even helped Alex with a few minor issues… but it has been a long time.

Best thing I’d suggest… is put your project aside for a while, and play with his demo… make changes to see how it affects the results. There is probably a ton of the features you may not even need/want.

[quote=90511:@Richard Summers]Mike,
The only problem I have experienced is that when I set the GutterWidth to 20 for example - the gutter width doesn’t change?
Do I also need to change it elsewhere?

Another small problem was that if I set the Insertion point to thick - it sometimes disappears - but I only want a normal insertion point - so for me - that is not a problem.

Also, can this be used on commercial projects, or do I need to purchase this from somewhere?

Thanks.[/quote]

I’m not sure on the gutter width I didn’t need to adjust it. Licence info can be found on the project home page on the LHS https://code.google.com/p/custom-editfield/

Do all MAS submissions have to be retina ready Dave?

Thanks.

Another option might be the Formatted Text Control http://www.bkeeney.com/formatted-text-control/. We’ve done a lot of work getting it Retina capable. There was a couple of user submissions about Retina that hasn’t been made public yet but I’m hoping to get them out this week.

FTC uses the TextInputCanvas now doesn’t it Bob ?
So it handles text input “correctly” according to OS X
Custom Edit Field can’t until / unless its updated to use the text input canvas

IF you happen to use Safari start a reply & just press & hold down the E key
You get a little popup with the variants with various accents etc
You can’t make that work unless you base your custom control on the TextInputCanvas
Not even with declares

Yes.

I actually own Bob’s FTC, but as a novice, it is a little bit too complex for me to use at the moment.
I simply wanted a TextArea with line numbers, but have had to settle for just the TextArea.

Maybe one day I will be advanced enough to understand that kind of stuff.

How did you get on with the custom edit field Richard

It worked fine, but it is not retina enabled, so I cant really use it in a commercial application if it will look blurred for Retina users.

Also, it requires an attribution link, which I think looks unprofessional on commercial software.