Jump to content

edit box DX


leshikgo

Recommended Posts

  • MTA Team

How to jump with the cursor?

Using the position, iterate through the visible text and checking if the delta position is greater or lower than the cursor position.

How to make a blinking caret?

Use that piece of code when drawing the caret line:

tocolor(0, 0, 0, math.abs(math.sin(getTickCount() / 300)) * 200) 

Link to comment

Note: string.split and table.size are usefull functions

  
local text "My Random generated string of text wich goes long" 
local str = string.split(text) 
local mstr = "" 
local boxStart = x*0.2 
local cursorPosition = x*0.3 
for i=1, table.size(str) do 
mstr = mstr..str[i] 
if cursorPosition <= dxGetTextWidth(mstr, scale, font) + boxStart then 
 -- Found da spot! 
end 
end 
  

You'd still need to do some maths to where to add more characters due to the nature of dxInput, but you can do it from here

Link to comment

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...