I’m having an issue where if the height of the application is set (in the config.lua) to above 85% (90% when statusbar is turned off) of the device’s aspect-height, the text selection for native.textField will break.
The selection drop-down bar options (cut,copy,etc) will pop-in for a moment and then dissapear. Along with that, the width of the frame also decreases while this is happening.
I believe it’s breaking because it doesn’t have enough space, and doesn’t know how to pan or move the application or overlay on the application? Those are just my theories.
Here is the stripped code I’m testing with.
main.lua
--the height of the statusbar also affects how high the application can be display.setStatusBar(display.DefaultStatusBar); --just so I can see how big the application size is local bg = display.newRect(display.contentCenterX,display.contentCenterY,display.contentWidth,display.contentHeight); bg.fill = {0.3} local textField = native.newTextField(display.contentCenterX, display.contentHeight\*0.3, display.contentWidth\*0.9, display.contentHeight\*0.1); textField.placeholder = "a textfield";
config.lua
--Rob's (I think) fit-all config code, causes text selection to break --local aspectRatio = (display.pixelHeight - display.statusBarHeight) / display.pixelWidth --application = { -- content = { -- width = aspectRatio \> 1.5 and 800 or math.floor( 1200 / aspectRatio ), -- height = aspectRatio \< 1.5 and 1200 or math.floor( 800 \* aspectRatio ), -- scale = "letterBox", -- fps = 60, -- imageSuffix = { -- ["@2x"] = 1.3, -- }, -- }, --} --this works on my Samsung Galaxy S3 (res:720x1280) application = { content = { width = 720, height = 1130, --any height roughly above that causes text-selection to break scale = "letterbox" }, }
build.settings
settings = { orientation = { default = "portrait", supported = { "portrait", "portraitUpsideDown",} }, iphone = { plist = { UIStatusBarHidden = false, CoronaWindowMovesWhenKeyboardAppears = true, } }, android = { coronaWindowMovesWhenKeyboardAppears = true, }, }
Notes for a report:
-
It matters if display.statusBar is set on or off, as it affects the native screen height available.
-
It does not matter if I have coronaWindowMovesWhenKeyboardAppears = true or false (panning still works just fine when it’s enabled, no worries there). But, the selection bar will show under the statusBar if false.
-
It does not matter what the total resolution is.
-
The aspect ratio (specifically the height of the application) affects whether text selection works or not.
I have tried the following four setups on my SGS3.
Works (causes blackboxes at top and bottom):
-
320x480
-
720x1130 (or 1180 with statusbar off)
Does not work (no black boxes):
-720x1280 (SGS3 resolution)
- 320x568 (1.778 aspect ratio)
If I build the Corona/SampleCode/Interface/NativeKeyboard to my SGS3, text selection works perfectly. If I modify it’s config.lua to use the device’s screen aspect ratio (such as Rob’s code) it breaks.
I am building on OSX with daily-build CoronaSDK-2015.2795
As far as I know, this is not an issue on iOS devices as they render the selection pop-up right above the text (I’m guessing this is constant across all iOS devices?)
I should probably also mention that my device is a SGS3 i9300 rooted, running a custom 4.1.2 android ROM (Omega v50.1 XXEMRG). Edit: I am now on ROM CM11 20150901 XNG3CAO3G0 (android 4.4.4), the problem still persists.
Can anyone with a spare 5 minutes who has an android, please test my above code using Rob’s auto config.lua code instead of mine (The code that’s been commented out). All you have to do is: uncomment rob’s code > remove mine > build it > install it to your device > run the app and type something into the text field, then attempt to select it by holding down on the text. You should expect to see the selection dialog at the top of your screen with cut, copy, etc.
If someone else replies confirming this on another device, I will make a bug report.