Wow! I will check out your plug-in as soon as I get home this evening!
Takker og bukker!
Ok, I’ve testet a bit and I don’t get it to work. It’s quite possible me who have done something wrong.
When I touch a text field, the keyboard shows up and the keys are all uppercase (since it’s the first letter in the text field), just as before:
Video:
I guess if things were working as supposed to, the keyboard would show all lowercase letters?
What I’ve done is this:
main.lua:
local keyboardEvents = require "plugin.keyboardEvents" -- Turn off auto capitalization for text fields and text boxes (only for iOS) keyboardEvents.init() keyboardEvents.setTextFieldAutocapitalizationType("None") keyboardEvents.setTextBoxAutocapitalizationType("None") keyboardEvents.setAutocorrectionType("UITextAutocorrectionTypeNo") keyboardEvents.setSpellCheckingType("UITextAutocorrectionTypeNo")
I added setAutocorrectionType() and setSpellCheckingType() for good measure.
I also called init() first.
I also added the following line under the plugins section in build.settings:
["plugin.keyboardEvents"] = { publisherId = "net.shakebrowser" },
Do you see any obvious errors in the usage?
Maybe I should try this instead (as this is how I require the other plugins that I use)?
local keyboardEvents = require("plugin.keyboardEvents")
Nah…last version didn’t make any difference (as I suspected).
BTW, I’m testing on a iPhone 5S running iOS 11.2.6
You need to do the calls after creating your text fields/boxes. Something like this:
local textField = native.newTextField( 150, 50, 180, 30 ) keyboardEvents.setTextFieldAutocapitalizationType("None")
Or if you need to change the autocapitalization type on different text fields you can set it in the began phase of the listener like this:
local function textListener( event ) if ( event.phase == "began" ) then keyboardEvents.setTextFieldAutocapitalizationType("None") end end local textField = native.newTextField( 150, 50, 180, 30 ) textField:addEventListener( "userInput", textListener )
Er du fra danmark siden du takker og bukker
Ok, so there is no harm calling setTextFieldAutocapitalizationType() mutiple times then (like after every call to newTextField() ) ?
Because it’s very hard to know when the last call to newTextField() is done…
I’ll check this out right now!
Jeg er nok hva dere kaller en “fjeldabe”…
No harm in doing that.
Godt at høre at der er fjeldaber i forummet også
Hey, this actually worked like a charm! Excellent work! If you had known how long I have been struggling with this and getting nowhere with Corona…
Please provide me with an email address (PM if you prefer) so that I can PayPal you a $15 donation.
Testing the app in iOS worked very well. Testing on an Android device, not so good. It immediately crashes with this message:
It seems just this line is enough to crash my Android (8.0) device (Samsung Galaxy S9):
local keyboardEvents = require("plugin.keyboardEvents")
This is not normal?
According to the Marketplace entry, this is an iOS only plugin but I’ll let @ojnab confirm that.
Rob
My apologies.
I have never used platform-specific plugins before. Actually I didn’t know it was even possible/legal.
And it never occurred to me that a require call to a plugin (that is not made for the current platform) could downright crash an app like that. This is a very ungraceful way of handling it IMHO. I was certain that in worst case it would return nil so that it could be handled properly.
But I learn new things every day…
A least now it works (after checking the platform before even doing the require call)!
Rob is right - it is iOS only.
Anyway it shouldn’t crash Android since I added an Android stub file to the repo.
The Android stub file is supposed to get downloaded in order to gracefully handle the missing Android functionality.
I am not sure what went wrong…
For now - to prevent Android crashes you can just create your own stub functions like this:
local keyboardEvents if system.getInfo("platform")=="ios" then keyboardEvents = require "plugin.keyboardEvents" else keyboardEvents = {} keyboardEvents.setTextFieldAutocapitalizationType = function() end keyboardEvents.setTextBoxAutocapitalizationType = function() end end
Ok thanks, I have made a common KeybSett() utility function (called after each newTextField()) and handled it more or less like this:
local keyboardEvents = nil if (onIOS() == true) then keyboardEvents = require("plugin.keyboardEvents") keyboardEvents.init() end KeybSett = function() if (onIOS() == true and keyboardEvents ~= nil) then keyboardEvents.setTextFieldAutocapitalizationType("None") keyboardEvents.setTextBoxAutocapitalizationType("None") keyboardEvents.setAutocorrectionType("UITextAutocorrectionTypeNo") keyboardEvents.setSpellCheckingType("UITextAutocorrectionTypeNo") end end
Maybe not so elegant, but it seems to do the job.
Yes it will.
Also you only need to do the keyboardEvents.init() call if you want to listen for keyboard events.
And by the way donations will not be necessary, but thanks for the offer :)
Ok, thanks a bunch then