I am using CCEditBox in the latest cocos2d-x 3.2 as textBox for user input.
now , i want to align text which i am typing in Textbox area , but it's always stays left align. i want to set it in the Center of my textBox.
I tried one Function named : setLabelAnchorPoint but it's not giving any effect to my label alignment. please help.
cocos2d::extension::Scale9Sprite *Playername_bgtemp = cocos2d::extension::Scale9Sprite::create("Name_bg.png");
auto _editName = EditBox::create(Size(1000,164), Playername_bgtemp);
Point absolutePosition = Point(ReferenceFrameSprite->getContentSize().width/2,4*ReferenceFrameSprite->getContentSize().height*0.20);
_editName->setPosition(absolutePosition);
_editName->setFontName("fonts/HelveticaLTStd-Cond_0.ttf");
_editName->setFontColor(Color3B::WHITE);
_editName->setLabelAnchorPoint(Vec2(0.0f,0.0f));
_editName->setPlaceHolder(" Name ");
_editName->setPlaceholderFontColor(Color3B::WHITE);
_editName->setPlaceholderFontName("fonts/HelveticaLTStd-Cond_0.ttf");
_editName->setMaxLength(10);
_editName->setReturnType(EditBox::KeyboardReturnType::DONE);
_editName->setFontSize(BgContentFontSize);
_editName->setDelegate(this);
bgFrameSprite->addChild(_editName,PopUpTag);
I did the trick with a text Label in the same position than the Editbox. I keep the Editbox with an empty string.
When start editing the edit box:
Hide the label.
Set the Editbox text with the label content.
When end editing the Editbox:
Set label text to Editbox content.
Show the label.
Set Editbox text to an empty string.
Related
I am making an image annotation system Using qrect and Simple text items.
I am trying to store the string values from the QGraphicssimpletext items into a JSON file to save and load the annotation boxes. The rectangles work fine but I cannot understand how to get a string value. This is the foreach I am trying to loop through for each item, and as the text items are children of the rectangles the position does not matter.
foreach(QGraphicsItem* item, items())
{
arrayPosX.push_back(item->x());
arrayHeight.push_back(item->boundingRect().height());
arrayWidth.push_back(item->boundingRect().width());
arrayPosY.push_back(item->y());
arrayAnnotation.push_back(item->?);
}
Both the simple text and rect items are added to the scene using
itemToDraw = new QGraphicsRectItem;
this->addItem(itemToDraw);
simpleTextToDraw = new QGraphicsSimpleTextItem;
this->addItem(simpleTextToDraw);
I would simply like to know how I could get the string values from the simple text item as to allow saving and loading of both strings and boxes, not just boxes which the current system can do.
You have to cast and verify that the pointer is not null:
// ...
arrayPosY.push_back(item->y());
if(QGraphicsSimpleTextItem* text_item = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(item)){
arrayAnnotation.push_back(text_item->text());
}
I currently have a combobox which displays a list of numbers which are retrieved elsewhere and stored into the variable "test". Every time another number is set for "test", that number will be added into the combobox list.
Is there a way where I can use a CEdit text box instead of a CComboBox to display my numbers?
This is how I have coded the combobox.
CComboBox *pCombobox = (CComboBox *) (GetDlgItem(IDC_ComboBox));
strNumber.Format(_T("%d"),test);
pCombobox->AddString(strNumber);
Any help would be appreciated. Thank you.
Presuming you have an appropriate edit control placed on your dialog with ID IDC_Edit for example, then get the existing string, append the new value to it, replace with new string.
CString text;
GetDlgItemText(IDC_Text, text);
if (text.IsEmpty())
text.Format(_T("%d"), test);
else
text.AppendFormat(_T(",%d"), test);
SetDlgItemText(IDC_Text, text);
Im making a quiz. And it works like this, When you are answearing a question, you have to click some buttons with text on them to answear.
Example () = button
(G) (L) (O) (R) (I) (O) (U) (S)
And they have to spell glorious in that label correctly. And when they click the answear button, if the label says Glorious, they go to the next level. And if it says something else like Gloirous a message saying wrong answear will come up.
The problem :
The problem is that when i click a button, it adds text to the label.
But when i click another button the previous text dissapears and the new comes in.
I hope you guys understand what i want here! My english is not the best but if you want me to post some code i can do that !;)
You need to save previous text, and append new text to previous.
label.setText(label.text() + newText)
Try this:
[yourLabel setText:[yourLabel.text stringByAppendingString:#"%#", yourButton.text]];
Don't save the text to a label. Display the text in a label, but store it somewhere else.
Create an instance variable "answerString". Append each letter to the answer string, and then display the answer string to your label:
NSString *answerString;
Also, don't write a different IBAction method for each button. Put numeric tags on each button, attach them to the same method, and use the tag number to figure out which button was pressed. Something like this:
typedef NS_ENUM(NSInteger, buttonTags)
{
aButton = 100,
bButton = 101,
cButton = 102
//and so on for the entire alphabet, or for the letters you need
}
- (IBAction) buttonAction: (UIButton *) sender;
{
int button_id = sender.tag;
switch (button_id)
{
case aButton:
answerString = [answerString stringByAppendingString: #"a"];
break;
case bButton:
answerString = [answerString stringByAppendingString: #"b"];
break;
}
answerLabel.text = answerString
}
If you have buttons for all 26 letters it probably makes more sense to do some math on the tag numbers to get the unicode value of each character rather than having a switch statement with 26 cases, but you get the idea.
I'm trying to insert tag next to specific text.
I was get a knowhow to insert tag next to text..
It is to use Setsel() and ReplaceSel().
example,
char str = "< name >";
m_richedit.Setsel( position of start dragging of text, end position )
m_richedit.ReplaceSel( str, TRUE )
but, I don't know how to get position of start dragging of text in richEdit.
Is there anybody who has an idea?
Thank you.
You need to add the appropriate accelerator key like they explain here: Adding accelerators(shortcuts) in MFC - HOW? . Then in the handler of the accelerator key, use GetSelText, add your tags to the string you get and call ReplaceSel.
I have a bunch of cells whose font size I'd like to tweak if their content is overflowing, until it all fits. I'd like to write a macro to do this, unless there's a conditional formatting or other formulaic way of doing it. Is there a property that tells whether a cell is overflowing? If so, what is it?
'open office 3
'get current document
oDoc = ThisComponent
' get first work sheet
oSheet = oDoc.getSheets().getByIndex(0)
'first cell in the work sheet
Cell = oSheet.getCellByPosition(0, 0)
MsgBox Cell.CharHeight
Happy Coading :))