Sign in to follow this  
derailed

Weird behavior with guiCreateLabel

Recommended Posts

Hi. I'm new to MTA scripting community. :) I created a login screen with two edit boxes and a label on top to create a custom input fields. Now, when I type in the letters, the black vertical line stays behind as I insert text. Thank you for your help in advance on how to fix this issue.

 

sWZXAsx.gif

 

Code:

loginLabels = { };
  
function updateLabels( )
    guiSetText( loginLabels[ source ], guiGetText( source ) );
end 

local loginBackground = guiCreateStaticImage(0, 0, guiGetScreenSize(), guiGetScreenSize(), loginSettings[0], false)

local loginWindow = guiCreateStaticImage(0, 0, guiGetScreenSize(), guiGetScreenSize(), loginSettings[1], false, loginBackground)	 

loginUser = guiCreateEdit( 0.292, 0.411, 0.155, 0.03, " ", true, loginWindow )
guiSetAlpha ( loginUser, 0 ) 
loginLabels[loginUser] = guiCreateLabel( 0.298, 0.418, 0.155, 0.03,"",true, loginWindow)
guiMoveToBack( loginLabels[loginUser] );
local loginFont = guiCreateFont(loginSettings[4], 14)
guiSetFont ( loginLabels[loginUser], loginFont )
guiLabelSetColor ( loginLabels[loginUser], 0, 0, 0)
guiBringToFront( loginUser )

loginPassword = guiCreateEdit( 0.292, 0.477, 0.155, 0.03, " ", true, loginWindow )
guiSetAlpha ( loginPassword, 0 ) 
loginLabels[loginPassword] = guiCreateLabel( 0.298, 0.483, 0.155, 0.03,"",true, loginWindow)
guiMoveToBack( loginLabels[loginPassword] );
guiSetFont ( loginLabels[loginPassword], loginFont )
guiLabelSetColor ( loginLabels[loginPassword], 0, 0, 0)
guiBringToFront( loginPassword )
guiBringToFront( loginUser )

addEventHandler( "onClientGUIChanged", loginUser, updateLabels, false );
addEventHandler( "onClientGUIChanged", loginPassword, updateLabels, false );

 

Share this post


Link to post

I think the problem is that the font size used by the actual input boxes (that you have hidden) is smaller than that of the labels used to show the input. So the text width doesn't match.

  • Thanks 1

Share this post


Link to post
1 hour ago, MIKI785 said:

I think the problem is that the font size used by the actual input boxes (that you have hidden) is smaller than that of the labels used to show the input. So the text width doesn't match.

Can one possibly set custom font on the text input as well?

Share this post


Link to post

Well, guiSetFont works for any GUI element, it's not limited to labels, so you can try that. But I really don't know if it will work.

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.