• DTextEntry
    2 replies, posted
I have met a problem with DTextEntry. I cannot let keyboard input in the text area. When text area is focused, the keyboard is still for controlling purpose, like moving or turning on the light. However, it is possible to right click the text area and choose copy, cut or paste there. If I copy something outside the game, it can be pasted in the text area and they can be read by Lua code. Here is my code [lua] local Frames=vgui.Create("DFrame") Frames:SetPos(25,50) Frames:SetSize(350,350) Frames:SetTitle("Simple Gear Train") Frames:SetVisible(true) Frames:SetDraggable(true) -- Draggable by mouse? Frames:ShowCloseButton(true) local myText=vgui.Create("DTextEntry",Frames) myText:SetMultiline(true) myText:SetEditable(true) myText:SetSize(200,200) myText:SetPos(30,30) myText:SetEnterAllowed(true) myText.OnEnter=function() LocalPlayer():ChatPrint("You wrote: "..myText:GetValue()) end myText.OnGetFocus=function() LocalPlayer():ChatPrint("I focus") print(myText:GetEnterAllowed()) end local myButtion=vgui.Create("DButton",Frames) myButtion:SetPos(45,310) myButtion:SetSize(200,30) myButtion:SetText("Ok") myButtion.DoClick=function() print(myText:GetValue()); LocalPlayer():ChatPrint("You wrote: "..myText:GetValue()) end [/lua] When I click the text area, "I focus" pop up, which means it focuses fine. However, "You wrote" in OnGetFocus never shows. Anyone know why the cannot input anything? Thanks a lot!
You need to use Frames:MakePopup() so that the frame takes control of the keyboard.
[QUOTE=Shatter;32423331]You need to use Frames:MakePopup() so that the frame takes control of the keyboard.[/QUOTE] It works, thank you!
Sorry, you need to Log In to post a reply to this thread.