By

Flex 4 – cut/Copy/Paste context menus not appearing

The right-click context menu for s:TextArea s:RichTextEditor, s:TextEdit, etc. is an expected feature for any sort of form functionality however a bug in s:Panel breaks this functionality whenever the control is inside an s:Panel item.

Note that this doesn’t affect ctrl+v/p/x keybindings – they work regardless.

There is a hack to get around this –  mark both the s:panel as well as it’s skin as mouseEnabled=”true”. What that means is that EVERY spark panel needs to have a custom skin with that override. This includes cases where there are two enclosing panels.

It’s a major pain, but it is a workable solution where needed. To create the skin, in eclipse:-

  1. Click ‘file’ > ‘new’ > ‘MXML Skin’
  2. Enter the name for the skin
  3. Set the HostComponent as ‘spark.components.Panel’
  4. Check ‘create as copy of’
  5. Set to copy ‘spark.skins.spark.PanelSkin’
  6. Click ‘finish’
  7. In the ‘<s:SparkSkin ..>’ tag set mouseEnabled=”true”
  8. Set  mouseEnabled=”true” on your ‘<s:Panel ..>’ tag
  9. On your ‘<s:Panel ..>’ tag set skinClass=”” to your new skin class

Now cut/copy/paste should appear in your context menu.

By

Flex Itemrenderer content overflow

There seems to be a problem with MXItemRenderer derivative classes resizing percentage-based widths.

datagrid:-

<mx:DataGrid id="dataGrid" dataProvider="{dataProvider}"
includeIn="data"
sortableColumns="false"
resizableColumns="false"
draggableColumns="false"
verticalScrollPolicy="on"
wordWrap="true"
variableRowHeight="true"
rowCount="10" maxHeight="500" width="100%">
<mx:columns>
<mx:DataGridColumn headerText="new data" itemRenderer="com.test.NewItemRenderer"/>
</mx:columns>
</mx:DataGrid>

newItemRenderer.mxml:-

<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"  focusEnabled="true" width="100%">
<s:Label text="{data}" lineBreak="toFit" width="100%"/>
</s:MXDataGridItemRenderer>

will cause the content to spill over into the next row (or clip if clipAndEnableScrolling is true) when the itemrenderer is recycled during scrolling the datagrid.
If I set the width to a pixel size it will draw correctly.

Only thing similar I have come across is this issue on stackoverflow

If anyone has a better workaround that can keep the percentage based width I’d love to hear it!