[Closed] Edit text and work wrap
from what i can see its not possible to set the text to wrap it just keeps scrolling off the edge to the right
Is this possible in regular max not DOTNet?
cheers
Does the height parameter not fix this?
From the help:
If an explicit height: parameter is supplied on an editText item definition that specifies a pixel height greater than one line of text (18 pixels), that editText item becomes a multi-line edit box, allowing multiple lines of text to be entered.
im setting the height to something like 50 and if you press enter it allows the user to go to another line but it will also let the user to write war and peace on one line
Why would you want to avoid dotnet anyway? Reinventing the wheel is always possible though rarely useful. As a starting point you can play with this annoying little snippet:
rollout warPeaceWrapper "Give me War and Peace" width:210
(
editText etWrapper "" width:200 height:200 align:#center
fn wrapLine str width =
(
fn addLine &str line =
(
if str != "" do str += "
"
str += line
)
local words = filterString str " "
local wrappedStr = ""
local line = ""
for word in words do
(
if (getTextExtent (line + word + " "))[1] <= width then
(
if line.count == 0 then line = word
else line += " " + word
)
else
(
addLine &wrappedStr line
line = word
)
)
if line.count > 0 do addLine &wrappedStr line
wrappedStr
)
on etWrapper changed text do
(
local wrappedText = stringStream ""
local lines = filterString text "
"
for i = 1 to lines.count do
(
format (wrapLine lines[i] 190) to:wrappedText
if i != lines.count do format "
" to:wrappedText
)
etWrapper.text = wrappedText
)
)
createDialog warPeaceWrapper
agreed but running your code didn’t work for me, unless i missed something that i was supposed to do, also enter or space keys didnt respond either. I have got examples of word wrap working with a dotNet textBox but it has to be in a dotNet form, otherwise the enter key wasnt getting picked up eben with the AcceptsEnter/AcceptsTab/Multiline all set to true.
Just seems a bit limiting that there isn’t something already as its such a fundamental for a text box
as you can see below .net TextBox works well in a rollout, and can gets Enter key to process.
try(destroydialog editor) catch()
rollout editor "Textbox In Rollout" width:300 height:200
(
dotnetcontrol tb "TextBox" pos:[0,0] height:20
fn initEditor =
(
tb.AcceptsReturn = tb.AcceptsTab = tb.Multiline = on
tb.WordWrap = on
tb.ScrollBars = tb.ScrollBars.Both
tb.Width = editor.width
tb.Height = editor.height
)
on tb KeyUp s e do
(
case e.KeyCode of
(
(e.KeyCode.Enter): s.SelectedText = "
"
)
)
on editor open do initEditor()
)
createdialog editor
i appreciate you time and posts so thanks, i shall have another go at this in the rollout i had. It clearly is possible with the Max rollout, dunno what i was doing wrong. This does answer my question though, Max doesn’t have a way of turning on word wrap natively