Focus editbox and bring up keyboard

I am pretty new to cocos2d-x and have understood that textfields with background etc is not something you should take for granted :smile: I have got everything to work with editbox but i have not found a way to use some sort of padding for the input text.

The only solution i could think of was to create a sprite/menubuttonimage and place it next to the editbox.

Question 1: Is there a better way to do this?

Question 2: What function should i use to focus the editbox and bring up the keyboard when for example touching a button cause i want the whole input area to be touchable?

Best regards

Hi @undrex

I didn’t quite understood your issue.
But I could help you with your second question.

try this -

this->_editBox->touchDownAction(this->_editBox, Widget::TouchEventType::ENDED);

while creating the editbox.
that would automatically invoke the editbox to come up with a keybaord.

Hope that helps… :smile:

Happy Coding.

2 Likes

Wow that worked!! Thanks alot m8!! :smile:

What i ment about padding is the margin of the text inside the editbox if i for example would want the text to be margined 10 pixels from the left to the right.

But this works just aswell :slight_smile: Thanks!!

glad it helped… :smile:

If I found anything for padding, I will let you know.
Happy Coding.

1 Like

@pabitrapadhy did You find anything about the padding issue?