Aligning text in DTextEntry

I’ve been cleaning up the Nutscript character menu since it was a bit cluttered and I was left with only small entry panel for the character description, which worked well with the more busy menu but now leaves it looking rather empty.

http://puu.sh/obDl9/a1fe97cc93.jpg

I’d like to make it so that rather than the tiny little strip, it looks closer to this:

http://puu.sh/obDu4/135e07becd.jpg

So I increased the “SetTall” value in the respective derma section and I’m left with this:

http://puu.sh/obDJo/386a70a5ab.jpg

How would I go about aligning the text so that it starts in the top-left corner, if possible with the way Chessnut coded it?

The code for the description’s derma section, as I have it now, is:


self.desc = self.info:Add("DTextEntry")
self.desc:Dock(TOP)
self.desc:SetFont("nutMediumLightFont")
self.desc:SetTall(308)

Try

Panel:SetMultiline, that works for me

Yeah, that works, but now I can’t actually set the description through that menu since “enter” is unhinged now :v: One problem fixed, lead to another.

Thanks, though!

Wait, so are you using enter to confirm the description or something?

[editline]9th April 2016[/editline]

Or is enter meant to be an unusable key?

In the original code you use “enter” to confirm that the info you put into the box is set as your cahracter description, which doesn’t work now since you can use “enter” to skip lines in the box. Trying to look into how to get around that right now.

Try overriding this function on your panel

[editline]9th April 2016[/editline]

Or just do



self.desc:OnKeyCode( key )

   if key == KEY_ENTER then
      --confirm stuff
   end

end


Been dicking around with that for a bit, but no dice.

It’s probably important to note that the self.desc part has two parts: the part I mentioned above, which goes like this now:


self.desc = self.info:Add("DTextEntry")
		self.desc:Dock(TOP)
		self.desc:SetFont("nutMediumLightFont")
		self.desc:SetTall(308)
		self.desc:SetMultiline(true)

Then this under a function PANEL:setup()


		self.desc:SetText(LocalPlayer():getChar():getDesc())
		self.desc.OnEnter = function(this, w, h)
			nut.command.send("chardesc", this:GetText())
		end

I’ve been messing with putting a SetEditable( false ) in the first part and adding a derma button to run the “CharDesc” command to open the manual window like that, but I’m horrible with derma and can’t get it working.

Wait, so what’s the problem with doing



self.desc.OnKeyCode = function( this, key )
   if key == KEY_ENTER then
      nut.command.send("chardesc", this:GetText())
   end
end


?

[editline]9th April 2016[/editline]

Also, I think the reason your OnEnter function wasn’t working is because that only gets run if the panel ISN’T multiline, as shown here.

[editline]9th April 2016[/editline]

Actually, the only problem I can see with doing that thing above is that you might have to string-sub out the newline character- but that should be easy enough to do for a sloth-thing wearing a hat like you, right?

…actually, that does work, I just didn’t notice because I had my headphones off and couldn’t hear the noise it makes to verify that the description’s changed. Thanks. I’ll just make it so the menu closes upon enter being hit as well.