img tag is not working properly in actionscript3 TextField - html

I have a TextField.
Here is a snippet:
this.textField = new TextField();
this.textField.defaultTextFormat = font.format;
this.textField.selectable = true;
this.textField.border = true;
this.textField.wordWrap = true;
this.textField.multiline = true;
And here is the method to add new line to the textField box:
this.textField.htmlText = 'some text <IMG SRC="http://gravitatestudio.com/wp-content/themes/gravitate/images/facebook.png">';
The issue is that an image is always placed UNDER text instead of the END OF THE TEXT.
Here is the trace(this.textField.htmlText) after html text has been added:
<P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="12" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0">some text <FONT SIZE="2"><IMG SRC="http://gravitatestudio.com/wp-content/themes/gravitate/images/facebook.png"> </FONT></FONT></P>
Also I need to add an image to any side of the text like a chat message using smiles (left, middle, right side of the text).
Any suggestions?

TextField html text is very limited and thats why Adobe released TLFTextFields which will give you much more control over the layout of elements in the field. I have personally used it and have made entire chats out of one textfield with images, links etc.
resource:
adobe: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/text/TLFTextField.html
tutorial:
http://flashsimulations.com/2010/09/10/handling-image-loading-in-tlf-textflow-and-textfield/

Related

how to Highlight read only Text Area based on deletes from another of same text area?

I have two text area with same content.One is read only text area and other is editable text area. When a user deletes any text using 'delete' or 'backspace' or 'ctrl+x'then that data need to be highlighted in read only text area. The highlight should always show up the difference between read only text area and editable text area. Any idea how to achieve this goal. Have tried few options nothing is working as expected. Experts help is greatly appreciated.
All this happening in one component.
HTML code:
<label class="edit-title">Topic Description (System, Read-Only)</label>
<textarea rows="14" cols="60" class="description edit-text-area" [(ngModel)]="data.topicDescLong" readonly></textarea>
</div>
<div class="topic-section topic-divider">
<label class="edit-title">Topic Description for Presentation</label>
<textarea rows="14" cols="60" class="description edit-text-area" [(ngModel)]="data.editedTopicDescLong" (ngModelChange)="onEditLongTopicDescChange()"></textarea>
</div>
Component Code:
onEditLongTopicDescChange(){
if(this.data.editedTopicDescLong.trim().length === 0 )
{
this.isSaveDisabled = true;
this.isSubmitDisabled = true;
}else{
if(this.orginalEditTopicLongDesc != this.data.editedTopicDescLong)
{
this.isSaveDisabled = false;
this.isSubmitDisabled = false;
}
else{
this.isSaveDisabled = true;
this.isSubmitDisabled = true;
}
}
}
When user Delete any text using 'delete' or 'backspace' or 'ctrl+x'
Then the selected text should be removed from the editable section
and highlight the deleted part on read only section. Sample Image Attached
Left is readonly text area and right is editable area.

How to set qlabel text's opacity in PyQt?

I have a label and I want to set it html\css formatted text from text variable.
label = QtGui.QLabel()
text = '''<font face="tahoma" color="#45688E">THIS TEXT</font>'''
label.setText(text)
I need the word THIS to be colored with my color(#45688E) and word TEXT to be transparent.
The idea is that I want label to show only one word on screen, meanwhile I could programatically get two words.
How to do it?
Thank you.
Update1: photo
Code:
from PyQt4 import QtGui, QtCore
import sys
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
window.resize(300, 400)
window.setWindowTitle('TITLE1')
window_layout = QtGui.QVBoxLayout()
window.setLayout(window_layout)
label = QtGui.QLabel()
text = '''<font face="tahoma"><span style="color:#45688E">THIS</span><span style="opacity:0"> TEXTANOTHER_WORD</span></font>'''
label.setText(text)
window_layout.addWidget(label)
window.show()
sys.exit(app.exec_())
Wrap your first word in a span tag and style with a color. Add all other words in another span tag and set the opacity of the span tag to 0
'''<font face="tahoma"><span style="color:#45688E">THIS</span><span style="opacity:0">TEXTANOTHER_WORD</span></font>'''
Browser Snippet below
<font face="tahoma"><span style="color:#45688E">THIS</span><span style="opacity:0">TEXTANOTHER_WORD</span></font>
EDIT:
Solution 2
'''<font face="tahoma"><span style="color:#45688E">THIS</span><span style="display:none">TEXTANOTHER_WORD</span></font>'''
A somewhat odd solution with PyQT
Somewhat setting the color to transparent hides that text
style="color:transparent"
Example
text = '''<font face="tahoma" color="red" style="color:green;"><span>THIS</span><span style="color:transparent">TEXT</span></font>'''
Picture below

Multiline Radiobutton

I've radio buttuons in my WP-8 application.
All contents of my radiobuttons are overlapping. I've fixed height and width but words are not wrapping to second line. How can I solve this problem?
Please do not say something like "\n" content is dynamic.
You are probably setting text to Content property as a string. But you can also use TextBlock.
XAML
<RadioButton>
<TextBlock Text="This is very long text that I want to wrap. Is it long enough?"
TextWrapping="Wrap"/>
</RadioButton>
C#
RadioButton rb = new RadioButton();
rb.Content = new TextBlock()
{
Text = "This is very long text that I want to wrap. Is it long enough?",
TextWrapping = TextWrapping.Wrap,
};
Result

Showing html text in FlowDocumentReader

I have a FlowDocumentReader control in my application.
<FlowDocumentReader Document="{Binding FlowDocument}" Style="{DynamicResource FlowDocumentStyle}" />
And here's how I set the text to the FlowDocumentReader:
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add("some <b>book</b>");
FlowDocument.Blocks.Add(paragraph);
The problem is that 'book' isn't shown like html, the tags are visible in the wpf application.
I tried using this converter:
http://code.msdn.microsoft.com/windowsdesktop/XAML-to-HTML-Conversion-ed25a674/view/SourceCode
but then the text shown in my wpf application looks like this:
<FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph>some <Run FontWeight="bold">book</Run></Paragraph></FlowDocument>
and again it's not bold. How can I do this?
Use UI Elements to show formatted text and them to InlineUIContainer of Paragraph.
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add("some");
Label lb = new Label();
lb.FontWeight = FontWeights.Bold;
lb.Content = " Book";
paragraph.Inlines.Add(new InlineUIContainer(lb));
this.Doc.Document = new FlowDocument();
this.Doc.Document.Blocks.Add(paragraph);

how do i set property of text box to UpperCase

I use following style attribute so when i will start typing in text box suppose 'railway'then it should get enter in text box like 'RAILWAY' without pressing CapsLock
<input type = "text" class = "normal" name = "Name" size = "20" maxlength = "20"> <img src="../images/tickmark.gif" border="0" style='text-transform:uppercase'/>
but I am not getting desired output by using this attribute
The best method would be to change the styling on your form to display uppercase:
input.normal
{
text-transform:uppercase;
}
SEE EXAMPLE
However this will not actually convert the string to uppercase, just style it to appear this way.
Therefore then when the data is submitted, use whatever server side language to convert the string to uppercase for purposes of storing in the database etc. For example with .NET you would do:
str.ToUpper();
You can accomplish this using CSS, if you only care about stylistic aspect:
.normal { text-transform: uppercase; }
If you need the text itself to be in all-caps (which is probably what you meant, sorry), combine with a bit of jQuery (it can be done without jQuery, too, but what's the point in that?):
$('.normal').change(function() {
$(this).val($(this).val().toUpperCase());
});
Example: http://jsfiddle.net/HackedByChinese/QwSSe/1/
You need to put your text transform in your Input tag, not your Image tag. Like this.
<input type = "text" class = "normal" name = "Name" style="text-transform:uppercase;" size = "20" maxlength = "20">
<img src="../images/tickmark.gif" border="0"/>