You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func
_evt(_ e:NSEvent) -> NSEvent?
{
if e.type == .keyDown
{
if let s = e.characters
{
if s.rangeOfCharacter(from: CharacterSet.alphanumerics) == nil
{
return e
}
if s.isNumber()
{
return e
}
return nil
}
}
return e
}
public func
use_filter()
{
NSEvent.addLocalMonitorForEvents(matching: [.keyDown], handler: _evt)
}
Call method use_filter()
mystepper1. use_filter()
Now you can hit only number in NSTextField (alphanumbers are correct check but if you hit "%" doesn't work!)
May be is utile for you in future version ?
The text was updated successfully, but these errors were encountered:
Ah that's a really good point mate -- I'd not thought about filtering the input field (rather just going 'beep' when the edited field is not a number!). Thank you for the idea and the code sample - I'll need to think about how to handle fractional values and locales too (ie. 10.5 here in Australia is 10,5 in Germany so its not as simple as a check for .) as the control can step by fractional values too, but its a really solid idea.
Hi,
I have add a simple function for check input on the NSTextField (macOS only)
Add this extension
Add this code on the stepper view class
Call method use_filter()
mystepper1. use_filter()
Now you can hit only number in NSTextField (alphanumbers are correct check but if you hit "%" doesn't work!)
May be is utile for you in future version ?
The text was updated successfully, but these errors were encountered: