Change screen shift of edit box

Change screen shift of edit box


I want to change the shifting behaviour of the edit box on mobile devices.
Right now, it is like that:
You touch the edit box.
The virtual keyboard appears.
If the edit box would be behind the keyboard, the whole screen is shifted upwards so that the edit box is right above the keyboard.

However, I would like to prevent the whole screen from scrolling. Instead, I only want the edit box to move to the top of the keyboard.

Does anyone know how I can achieve that?

Best regards



abandon those code in engine and try again
this is works on android

on iOS, you need plus “window.scrollTo(0, 0)” to pull down the window



I forgot to mention, I am using v1.10.2, and I couldn’t find this code in engine/cocos2d/core/editbox/CCSGEditBox.js

However, I am not that happy with the v1.10.2 EditBox anyways (for example because of the missing text alignment). I like to stick to v1.10.2 however because of the performance.

Could you maybe explain to me how I can integrate for example the v2.1.0 EditBox into the engine used by v1.10.2 cocos creator?



can not use v2.1.0 editor box with 1.10.2 cocos creator.because v2.x had different render flow with v1.x
you can upgrade your project to v2.1.0 cocos creator, and then try to use this solution.

besides, it is hardly to change the keyboard and screen event.because that cocos creator do nothing extra, just used system in mostly case the editorbox behavior is rely on browser and system event



Unfortunately downgrading is not an option because we have limited time and we are using some depreceated APIs.
So I tried to modify the above mentioned file (engine/cocos2d/core/editbox/CCSGEditBox.js), but apparently these changes aren’t taken into account. I inserted some cc.error outputs, but I can’t see them in my logcat when running the app on my phone (Yes, I built the apk in debug mode. I can see cc.errors I put into my own scripts).
Do I have to do anything for actually using the changed engine?
I am using the binary template to build the apk.

And yeah, I understand that. Now I am trying to play around with it to see what I can do and what I can’t do.