Jump to content

Editbox - cant type anything


XJMLN

Recommended Posts

Posted

Hi, i create panel login all works fine but is one small bug i cant insert any word to editbox. But if i'll keep LMB then i can entry word. Someone have that bug and fix it?

  
function displayLoginPanel() 
    showCursor(true) 
    showChat(false) 
    showPlayerHudComponent("all",false) 
    guiSetInputMode("no_binds_when_editing") 
    g_e_login = guiCreateEdit(sw*99/mw,sh*215/mh,sw*250/mw,sh*27/mh,"",false) 
end 
  

  • Moderators
Posted

You have to focus on the element before you can edit it. That is just how it is suppose to be, it is not a bug.

There are afaik no functions to change the element focus manually.

Although there are some workarounds like: https://wiki.multitheftauto.com/wiki/OnClientKey

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

ce91754a94bf78bd654fbe6d8fbc22b9.gif

On gif you can see what is doing when i click on edit, i think is bug or something block insert text to edit. ;(

Edit:

In GUIEditor editbox work fine, only in my code something is bad.

Posted
You have to focus on the element before you can edit it. That is just how it is suppose to be, it is not a bug.

There are afaik no functions to change the element focus manually.

Although there are some workarounds like: https://wiki.multitheftauto.com/wiki/OnClientKey

You mean guiBringToFront?

  • Moderators
Posted
You have to focus on the element before you can edit it. That is just how it is suppose to be, it is not a bug.

There are afaik no functions to change the element focus manually.

Although there are some workarounds like: https://wiki.multitheftauto.com/wiki/OnClientKey

You mean guiBringToFront?

No, check this.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
  
function isMouseIn(psx,psy,pssx,pssy,abx,aby) 
    if not isCursorShowing() then return end 
    cx,cy=getCursorPosition() 
    cx,cy=cx*sx,cy*sy 
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then 
        return true,cx,cy 
    else 
        return false 
    end 
end 
  
if isMouseIn(here code from guiCreateEdit,"",true) then guiEditSetCaretIndex(g_e_login,1) end 

That be good? Or better idea is eventHandler onClientClick and then code from up?

EDIT: I create that code, but when i click on editbox nothing happen ;/.

    addEventHandler("onClientGUIClicked",g_e_login,setIndexInput, false) 
    addEventHandler("onClientGUIClicked",g_e_password,setIndexInput, false) 
function setIndexInput() 
    local tlogin = guiGetText(g_e_login) 
    local plogin = guiGetText(g_e_password) 
    if source == g_e_login then 
        local textLength = string.len(tlogin) 
        if (textLength) > 0 then  
            guiEditSetCaretIndex(source,textLength+1) 
            outputChatBox("1") 
        else 
        setTimer(function() guiEditSetCaretIndex(source,1) end,500,1) 
         
        end 
    end 
    if source == g_e_password then 
        local textLength = string.len(plogin) 
        if (textLength) > 0 then 
            guiEditSetCaretIndex(source,textLength+1) 
            outputChatBox("1") 
        else 
        guiEditSetCaretIndex(source,1) 
        outputChatBox("1") 
        end 
    end 
end 
  

Posted

Okey, its work end code:

  
addEventHandler("onClientGUIClick",g_e_login,test, true) 
function test () 
    setTimer(setIndexInput,2000,1) 
end 
function setIndexInput(akcja) 
    local tlogin = guiGetText(g_e_login) 
    local plogin = guiGetText(g_e_password) 
        local textLength = string.len(tlogin) 
        if (textLength) > 0 then  
            guiEditSetCaretIndex(g_e_login,textLength+1) 
        else 
        guiEditSetCaretIndex(g_e_login,1) 
        end 
    end 
  
  

Close.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...