[Closed] Scrollable text-area type field?
Hi,
I’m aware I can make an edittext field in maxscript multi-lined, but if you go past its boundary, there is no scroll bar available. I am wondering if it is possible to have one somehow?
Thanks
As fas as I can tell, no. There’s really not a lot of props and methods to a UI component.
The only thing I can think of is that you count the lines in your text and make some visible clue for users to see there’s more text below… but I don’t think you can make a control to move the text up and down…
maybe look into activeX or dotNet controls? I have no experience with those though, can’t help you there.
-Johan
Well if you don’t need to be able to type into it then use a list box and read the lines as a stringstream and add them to the listBox array. .net or active X might be better choices but I don’t know of the control that you would be looking for.
Hmm… I was dreading those answers…
The thing is, I do need to type into it. I was hoping for something similar to a <textarea> HTML tag, but as a UI element in max. Will have to think about this later…
Thanks anyway though…
wouldn’t it be possible to just update the #width as the user types?
Here’s a .NET TextBox that supports scrollbars, multilines, and returns:
(
fn formatTextBox tb =
(
tb.multiline = true
tb.wordwrap = false
tb.acceptsreturn = true
tb.scrollbars = (dotnetclass "System.Windows.Forms.ScrollBars").vertical
)
rollout textBoxRollout "Text Box"
(
dotnetcontrol tb "System.Windows.Forms.TextBox" width:290 height:300 align:#center
button printText "Print Text"
on tb KeyPress sender event do
case event.keychar of
(
("\r"):(event.keychar = "
") --replace returns with newlines
)
on printText pressed do print tb.text
on textBoxRollout open do formatTextBox tb
)
createdialog textBoxRollout width:300
)
Hope it helps. There are quite a lot of methods and properties involved with this control, look up System.Windows.Forms.TextBox and TextBoxBase classes for everything you can do. If you can’t achieve what you need, you can always use the WndProc method and catch/replace the Windows messages yourself. Or you could write a C# inherited version if you want to get crazy.
edit: Sorry! I forgot to say that I had to handle the KeyPress event b/c .NET handles newlines as carriage returns, so I just swapped them out. I also believe tabs aren’t working, even if you set AcceptsTab = true. If you really need it, I believe you could insert the into the .text property of the control and it would work.
Ah, thank you very much! I haven’t tried it yet, but will let you know what happens.
I was also thinking, Is there any way to have the script editor open, in much the same way as PFlow does for its Script Operator, or even on the node itself, under the Script rollout, when you click “Edit”? Because if I can somehow do that, it would be ideal.
But I’ll definitely take a look at the control you made, d3coy, thank you very much indeed.
EDIT:
Just tried it, seems to work quite nicely – except my Enter key doesn’t seem to work. Did it work for you?
You could apply a Custom Attribute to the object which has a simple UI with a button that launchs the script. The UI would come up in the control panel when in modify panel.
Keith Morrison
www.focus360.com
Right, that’s what I want to do – but how would I launch the script editor? And have it kind of saved in-memory like the Script operator in PFlow? And perhaps have it auto-save when you close it.
You can launch new editor windows, with newscript() and edit <filename>. Do a search in the docs for “editor” and you’ll see the methods. As far as I know there is no event that fires when you close the window; the user would have to know to save before he/she closed the editor. My enter key did work once I put that code to swaps carriage returns for newlines though. You might want to play with it and see what it is detecting when you press enter and swap out the correct character.