PDA

View Full Version : Scrollable text-area type field?


scorpion007
06-15-2007, 12:38 PM
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

JHN
06-15-2007, 01:42 PM
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

PEN
06-15-2007, 02:12 PM
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.

scorpion007
06-15-2007, 02:27 PM
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...

MoonDoggie
06-15-2007, 03:16 PM
wouldn't it be possible to just update the #width as the user types?

d3coy
06-15-2007, 04:07 PM
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 = "\n") --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 \t into the .text property of the control and it would work.

scorpion007
06-16-2007, 01:47 AM
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?

Kramsurfer
06-16-2007, 03:30 AM
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

scorpion007
06-16-2007, 06:00 AM
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.

d3coy
06-18-2007, 03:27 PM
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.

scorpion007
06-18-2007, 03:35 PM
Ah, thanks for the tips, will have to look into it more thoroughly :)

Jon-Huhn
01-12-2008, 04:42 PM
James,

I just came across this code you posted for a .net TextBox, and I can't get the KeyPress handler to detect that the "enter" key has been hit at all. Was it working for you?

I'm using Max 2008.

Thanks!

CGTalk Moderation
01-12-2008, 04:42 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.