# InputField with Scrollbars [duplicate]

Edits are marked in bold:

How do I make an InputField that behaves just like the following HTML Textarea example.

<textarea rows="4" cols="50">
1
2
3
4
</textarea>


Specific Features that are ideal:

1. Text box has fixed height with scrollbar (The scrollbar must shrink to content size)
2. Ctrl+a selects all content
3. Enter key works correctly (The InputField auto scrolls to bottom as user inserts new line)
4. The text wrapping works appropriately

I looked through the docs unable to find an example that follows those specifications.

This question is quiet close, but I can't seem to keep the content autoscrolled when the user enters a new line and the text wrapping isn't working correctly.

-

## marked as duplicate by Leonid Shifrin, halirutan, Artes, Yves Klett, m_goldbergJun 15 '13 at 17:56

concerning the Enter key see : mathematica.stackexchange.com/q/6457/5467 –  andre Jun 15 '13 at 8:08
On my system (OS X), I can start a new line in your input field by entering Ctrl-J. –  m_goldberg Jun 15 '13 at 8:23
@LeonidShifrin The linked question works quiet wells except it doesn't have scrollbar support that I am aware of. Are you aware of way to possible fix this? –  Liam William Jun 15 '13 at 16:49
@LeonidShifrin I have modified it to support the scrollbar, but I have amended the specifications slightly. Ideally the scrollbar should autoscroll to the bottom when a user enters a new line. –  Liam William Jun 15 '13 at 17:10
@Liam I have been thinking about it, for my own purposes, but did not implement yet. Similar scrolling issues have been discussed before here and in the question of which that one is a duplicate. –  Leonid Shifrin Jun 15 '13 at 19:03

Perhaps this slightly modified version of your code is closer to what you want. Remember, Ctrl+J, not Enter, to start a new line.

DynamicModule[{data = "some\ndata"},
Column[{
Framed[
Pane[InputField[Dynamic@data, String,
ContinuousAction -> True,
Appearance -> None,
FieldSize -> {Automatic, {1, Infinity}}],
ImageSize -> {300, 100},
ImageMargins -> 0,
AppearanceElements -> {},
FrameMargins -> {{5, 5}, {0, 0}},
Scrollbars -> {False, True}],
Background -> White,
FrameMargins -> 0,
FrameStyle -> Gray],
Dynamic@data}]]


-
Crtl+J does not work for me (Win7), but it showed me how to add tags to current cell what I find useful. :) –  Kuba Jun 15 '13 at 10:07
@Kuba. Perhaps someone using Window can tell us what keystroke will work there. –  m_goldberg Jun 15 '13 at 10:48
I have noticed that if you type in text until the end of the line, that it wraps quiet funny. The text doesn't doesn't appear to fill up the first line before going onto the next. Additionally I noticed if I start pressing the space bar the text wraps a lot sooner then where the scrollbar is. After some trail and error it seems FieldSize -> {30, {1, Infinity}}],FrameMargins -> {{0, 0}, {0, 0}} seems to fix the 2nd issue, but I'm not so sure about the text wrapping issue. –  Liam William Jun 15 '13 at 16:28
@Kuba I have edited the code to use EventHandler to get around the Enter key issue. pastebin.com/n6eDPzaX I am not going to make this answer correct yet to see if someone comes up with a better answer(well shorter), more importantly the text is wrapping is wrong making the editor quiet difficult is use. –  Liam William Jun 15 '13 at 16:45