Hi, I am using a custom font that does not include some special characters.
I create an input text field using this font, but special characters like “@” turn up blank.
Is there a way to restrict the keyboard from allowing these symbols?
I know there’s inputType, but there doesn’t seem to be an optiom for just alphanumeric characters (without the symbols).
Any help would be great!
Thanks,
G [import]uid: 146743 topic_id: 31039 reply_id: 331039[/import]
Hey, @garry.law, I implemented a workaround that essentially disallows non-alphanumeric characters. It looks something like the code below. It’s not exactly how I have mine implemented, but it pretty much captures the essence. I hope this will at least help you come up with a solution that works for you.
Naomi
local function fieldListener( event )
if ( "began" == event.phase ) then
-- do whatever you need to do here
elseif ( "editing" == event.phase ) then
if not event.newCharacters:match("[%w%s]+") then
local prevPos = event.startPosition - 1
-- myObj is the textField object
myObj.text = string.sub(myObj.text,1,prevPos)
-- plan on playing a tiny beep sound to alert the user
end
elseif ( "ended" == event.phase ) or ( "submitted" == event.phase ) then
-- do whatever you need to do here
end
end
[import]uid: 67217 topic_id: 31039 reply_id: 124123[/import]
amazing, thanks!
[import]uid: 146743 topic_id: 31039 reply_id: 124239[/import]
Hey, @garry.law, I implemented a workaround that essentially disallows non-alphanumeric characters. It looks something like the code below. It’s not exactly how I have mine implemented, but it pretty much captures the essence. I hope this will at least help you come up with a solution that works for you.
Naomi
local function fieldListener( event )
if ( "began" == event.phase ) then
-- do whatever you need to do here
elseif ( "editing" == event.phase ) then
if not event.newCharacters:match("[%w%s]+") then
local prevPos = event.startPosition - 1
-- myObj is the textField object
myObj.text = string.sub(myObj.text,1,prevPos)
-- plan on playing a tiny beep sound to alert the user
end
elseif ( "ended" == event.phase ) or ( "submitted" == event.phase ) then
-- do whatever you need to do here
end
end
[import]uid: 67217 topic_id: 31039 reply_id: 124123[/import]
amazing, thanks!
[import]uid: 146743 topic_id: 31039 reply_id: 124239[/import]