cocos2d-objc icon indicating copy to clipboard operation
cocos2d-objc copied to clipboard

CCTextField textField property is always nil

Open TimPelgrim opened this issue 10 years ago • 7 comments

I looked into the code and it seems that the property relies on the "nativeTextField" property of the CCPlatformTextField which in the current version I am using is not set in CCPlatformTextFieldIOS.

TimPelgrim avatar Dec 16 '14 13:12 TimPelgrim

This used to work in like 3.2, but stopped working along the way... this really needs fixing!

jonnyijapan avatar Jan 28 '15 06:01 jonnyijapan

It's now been merged into V3.4

RobBoluga avatar Jan 28 '15 08:01 RobBoluga

Not entirely sure but I tried using your fix (thanks!) but it seemed like it had some problems with hiding/unhiding the uitextfield when CCtextfield was hidden/unhidden. I still have some more testing to do... busy with other things as usual... I'll just say the error can be on my side... Well this all used to work back last summer with whatever version was out then.

jonnyijapan avatar Jan 28 '15 08:01 jonnyijapan

This is because in CCTextField the update: is constantly setting the visibility of the UITextField based on the visibility of itself and it's parent nodes. So it's a separate issue. Why do you want to set isHidden on the UITextField rather than visible on the CCTextField?

RobBoluga avatar Jan 28 '15 09:01 RobBoluga

Anyway, I tried this out on a quick test project and it seems to work. My real project issue was probably caused by something else.

jonnyijapan avatar Jan 28 '15 10:01 jonnyijapan

@RobBoluga I've had a case where I wanted to hide just the UITextField and not the whole node - basically when covering up a CCTextField with another dialog - it looked better to just remove the text rather than the whole TextField node as sometimes the node is only partially covered, and during animations where the timing of when to hide the textfield was tricky to get right. I ended up subclassing CCTextField and overriding 'update' to honour a new property of 'just hide the UITextField' after calling super.

richardgroves avatar Jan 28 '15 11:01 richardgroves

Noticed this issue still exists when building for OSX, just copied @RobBoluga solution over to the CCPlatformTextFieldMac.m (#1373)

twomedia avatar Mar 21 '16 10:03 twomedia