Making Flex HTML Control UnSelectable - apache-flex

I am displaying some HTML text in an Adobe AIR Application that I do not want the user to be able to cut and paste. How do I make the HTML control disallow highlighting of the HTML without disabling the ScrollBars. mouseChildren=false works but disables the scrollbars which is unacceptable. Right now I have:
<mx:HTML location="http://dexter/preview.html" width="100%" height="100%" id="PreviewArea" x="0" y="0" tabEnabled="false" tabChildren="false" focusEnabled="false" focusRect="null"/>
But it's not working properly either.
I have also tried overlaying a disabled transparent text control over the top of the HTML component, but the user is still able to tab to the HTML and use the keyboard controls to copy the text to the clipboard.
Any hints?

You probably have to extend the HTML Component. Make the scroll bars, if applicable, usable, but apply set mouseEnabled, mouseFocusEnabled, mouseChildren, and focusEnabled to false on the inner display.
Alternatively, you could wrap the HTML component in a canvas. Set the HTML Component to it's measured height and measured width. Set the HTML Component to be 'unusable' with the above properties, but make the canvas usable.
Doesn't the HTML component display renderered HTML; not HTML Text? If you're displaying HTML Text, then you can use the TextArea and set editable and selectable to false.

Related

<mx:ButtonBar/> set width for individual buttons

I have a buttonbar which has both buttons with only small icons and buttons with short text labels. Problem is that each button gets huge padding while I want to set width of the button relative to its contents. Below is illustration of my problem:
Current one http://i.imgur.com/I8goS.png
With buttonWidth=32 http://i.imgur.com/s0fD5.png
I can set buttonWidth to 32 for my buttonbar which works fine for my icons, but not for text. Is there way to remove that huge padding of the buttons?
If I understand what you are after there, you can use a layout inside the buttonbar tag something like this:
<s:layout>
<s:HorizontalLayout variableColumnWidth="true" gap="0"/>
</s:layout>

flex mobile: cropped delete icon on ipado on textInput component

here is my CSS for textInput
s|TextInput{
skinClass: ClassReference("spark.skins.mobile.TextInputSkin");
contentBackgroundColor:#FFFFFF;
focusAlpha:0;
showPromptWhenFocused:false;
}
and I use simple:
<s:TextInput id="id1" />
<s:TextInput id="id1" height="40" />
<s:TextInput id="id1" height="60 />
On iphone/ipad: the close icon appears top cropped:
Any idea how to fix that ? (or even how to remove that X icon) ?
The icon is a set height and, at least in Flex, doesn't adjust its size. The cropping is from the height of the textfield (read: not the TextInput component, but the actual field the text goes in). Because that field is not as tall as the icon, the icon gets cropped.
There are two solutions:
The obvious one is to increase the height on the TextInput field until that icon is no longer cropped. You could just take your screenshot and measure out the pixels being cropped, if you want.
You get that icon because TextInput uses StageText. StageText uses native text rendering as opposed to Flash text rendering. In ideal situations, StageText is perfect. However, the situation is rarely ideal. To get around this, you simply apply the mobile TextInput skin skinClass="spark.skins.mobile.TextInputSkin" to your TextInput component(s). As www.Flextras.com pointed out to me yesterday, this reverts the TextInput back to its behavior prior to Flex 4.6, which introduced StageText.
Either one of those solutions should work for you. You just need to choose which is best. I prefer Option #2 because, as I mentioned, there are other issues with StageText (such as getting displayAsPassword to function correctly) that switching to that skin fixes
I would try editing the skin, because that is where the icon crop is happening

styling images in spark textarea

This example shows how you can have Images in your spark TextArea and set their float and paddingLeft/paddingRight properties:
<s:RichEditableText id="myRET1" width="300">
<s:textFlow>
<s:TextFlow columnWidth="290">
<s:p id="p1">Images in a flow are a good thing. For example, here is a float.
<s:img id="image1" float="none" source="#Embed(source='../assets/bulldog.jpg')" paddingRight="10" paddingTop="10" paddingBottom="10" paddingLeft="10">
</s:img>
Don't you agree? It should show on the left. If it doesn't show up on the left, then it is a bug. You can submit bugs at http://bugs.adobe.com/jira/. You can set how the float is positioned within
the paragraph by using the ComboBox below. You can select left, right, start, end, or none. This example does not use the clearFloats property. That is in a different example.</s:p>
</s:TextFlow>
</s:textFlow>
</s:RichEditableText>
Is it possible to specify the image's float/padding via Flex's CSS?
yes it's possible to specify the image via css :
1)create a skin contains this image and those properties(padding)
2)create file css contains name space of component and call class reference (the class passed as parameter skins)
3)define in file mxml the style name equal the name space specified in steps 1

Resizing Textbox/textarea to fit text

I need to create user control with Texbox Textmode="Multiline" or html textarea.
When in edit mode Textbox/textarea has to be resizable. I can use some jquery plugin for this. But in read only mode this Textbox/textarea is disabled and it must be automatically resized (height) to fit the text. Even if text takes pages. I could just hide Textbox/textarea in read only mode and display text in div but I would like to keep edit and readonly page look same.
Any ideas?
Why have textarea/input in readonly mode - versus using js to switch back and forth between that control and a DIV or a P tag (to display the text), where simply by not setting the height (or setting it to height:auto) that box would automatically size to contain all text?
Also, unless your surrounding content doesn't allow that, enable resizing the textarea to the user; see http://davidwalsh.name/textarea-resize

What's the best way of creating a body of text with a text bubble background?

im new to flex, so naturally I would just create a dynamic sprite using the drawing api and put it behind the text... but my app is really buggy using the rawChildren to addChild.
So is there a better way to have a bg for a piece of text though actionscript?
like modifying an existing component?
I would place the text inside a canvas, and then apply a custom borderSkin to the canvas it's inside. ie:
css:
.textBubbleBackground{
borderSkin: Embed(source="img/textBubble.png",
scaleGridTop="10", scaleGridBottom="100",
scaleGridLeft="10", scaleGridRight="150");
}
mxml:
<mx:Canvas styleName="textBubbleBackground">
<mx:Text text="my text" />
</mx:Canvas>
Obviously that's a bit over simplified and you'll need to apply the proper 9 grid scaling to the background image (or I'd draw it programatically using degrafa, but that's a bit more complicated to explain)

Resources