Startseite › Foren › Deutsches LiveCode-Forum › Fit Content › Antwort auf: Fit Content
März 22, 2019 um 00:43 Uhr
#13686
Habe da ein kleines Beispiel probiert, das aber nicht macht was ich mir erwartet hätte.
zwei Felder: myField, myText
ein Button: addmyText2myField
die 3 Elemente zu einer Gruppe zusammengefasst und hier die beiden Skripts:
im Button:
on mouseUp
if fld "myText" is not empty then
if fld "myField" is not empty then
put the text of fld "myField" into tTemp
put tTemp & return & the text of fld "myText" into fld "myField"
changeFldHeight
else
put the text of fld "myText" into fld "myField"
changeFldHeight
end if
end if
end mouseUp
und in der Gruppe (habe zuvor im Feld „myField“ mit on textChanged versucht auf Änderungen zu reagieren, aber die Message wird scheinbar nicht ausgelöst!?):
command changeFldHeight
put the topLeft of fld "myField" into tTL
put the number of lines of fld "myField" into tN
put return & tN after msg
put the textHeight of fld "myField" into tTxHg
put 0 into tNewHg
if tN > 1 then
repeat with x = 1 to tN
put the textSize of line(x) of fld "myField" into tTxSz
put the spaceBelow of line(x) of fld "myField" into tSpBw
put the spaceAbove of line(x) of fld "myField" into tSpAb
add (tTxSz + tSpBw + tSpAb) to tNewHg
put return & "Neue Höhe: " & tNewHg & " nach Zeile: " & x after msg
end repeat
else
put the textSize of line 1 of fld "myField" into tTxSz
put the spaceBelow of line 1 of fld "myField" into tSpBw
put the spaceAbove of line 1 of fld "myField" into tSpAb
add (tTxSz + tSpBw + tSpAb) to tNewHg
put return & "Neue Höhe: " & tNewHg & " nach Zeile 1." after msg
end if
--set the height of fld "myField" to tNewHg
--set the topLeft of fld "myField" to tTL
end changeFldHeight
die neue Zeilenhöhe bleibt immer bei 0?! Sieht jemand von Euch was ich falsch gemacht habe?
Wieder zähle ich auf euer Feedback und eure Unterstützung.
Gruß
Georg