• Custom chat
    16 replies, posted
Hi guys, I'm trying to make a custom chat, but hiding the default with [code]function GM:HUDShouldDraw( name ) if ( name == "CHudChat" ) then return false end return true end[/code] I remove the default chat as I want but now, I can't type in chat. So I have this question : How can I "handle" chat writing with custom chat and hiding the default ? Thank you in advance.
You need to create your own entry for where to type, like DTextEntry. Then push that up to the server to "say" using the say or say_team commands.
No need DFrame with DTextEntry, I can use directly ?
You can use it directly without the DFrame.
Ok, thank you. I will try it.
You will need a panel of some sorts so the text entry can get focus. I use EditablePanel, which is invisible. You can use DFrame if you want since DFrames derive from Editablepanel.
Panel:Close() doesn't exist with EditablePanel so I tried to use SetVisible(false) but this makes some focus bug. Do I have an other way to close EditablePanel ?
Use MakePopup to get focus an have textEmtry:RequestFocus()
I did this but I have some problems with closing correctly... If I use Panel:SetVisible(false), sometimes, gmod is stuck :/
Works fine for me.
For me, sometimes, the DTextEntry doesn't drop the focus and I need to restart the game :/ Post my script : [code]pulpmod.chat = {}; Msg("[PULP_API] Loading CHAT API ...\n"); if SERVER then end if CLIENT then pulpmod.chat.posX = 0 pulpmod.chat.posY = ScrH()-300 pulpmod.chat.width = ScrW()/3 pulpmod.chat.height = 200 pulpmod.chat.inChat = false pulpmod.chat.teamChat = nil function pulpmod.chat.drawer( name ) end hook.Add("HUDPaint", "pulpmod.chat.drawer", pulpmod.chat.drawer); function pulpmod.chat.StartChat(isTeamChat) -- Création de vgui pour le tchat local DermaPanel = vgui.Create("EditablePanel") DermaPanel:SetPos( 100, 100 ) DermaPanel:SetSize( 300, 200 ) DermaPanel:MakePopup() local DermaTextBox = vgui.Create("DTextEntry",DermaPanel) DermaTextBox:SetPos(25, 50) DermaTextBox:SetTall(20) DermaTextBox:SetWide(250) DermaTextBox:SetEnterAllowed(true) DermaTextBox.OnEnter = function() Msg( "You pressed enter and the value was: " .. DermaTextBox:GetValue() .. "\n" ) DermaPanel:SetVisible( false ) end DermaTextBox:RequestFocus() DermaPanel:SetVisible( true ) return true end hook.Add( "StartChat", "pulpmod.chat.StartChat", pulpmod.chat.StartChat ) end[/code]
Up ! Did I forget somethings to do to tell when chat typing is done ?
I really need help for this. When typing is finished and press enter, the player cannot move again ...
Try calling DermaPanel:Remove() instead of DermaPanel:SetVisible( false )
Thanks. Working better, but player need to press enter again or escape to give focus to game :/ Something to fix this ?
My first problem is solved ! But now, the player needs to give again focus to gameby pressing enter ... Someone know how to fix this ?
Not sure what you mean by giving focus back to the game... It should do that when you remove the parented panel. If not the only think I could think to do is add this line on your enter function: gui.EnableScreenClicker(false )
Sorry, you need to Log In to post a reply to this thread.