Thread Tools Display Modes
06-08-20, 07:39 PM   #1
Yakkers
A Deviate Faerie Dragon
Join Date: May 2020
Posts: 10
How do I force an editbox widget to numberic but allow negative?

I'm working on basic settings window for my hit combo popups addon, I'm trying to make a pair of editboxes where the user can set X and Y offsets from the center of the screen. Using the center is the most intuitive way to do it, so I'm trying to figure out how I can get it to allow negative numbers.

Using SetNumeric() or GetNumber() doesn't do it, the former won't let the user type in a negative value and with the latter it'll treat a negative value as non-numeric and just default it to zero.

Is there something else in the EditBox widget I'm not seeing that lets me do this, or is there maybe a different widget I should be using?
  Reply With Quote
06-08-20, 09:32 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
When the user enters a value, run it through local number = tonumber(input) which will accept negative numbers. If tonumber returns a number, accept the value and continue. If it returns nil, reset the EditBox to the last value, maybe even give an error.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How do I force an editbox widget to numberic but allow negative?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off