Adobe air - add context menu on right click of tree node - air

I am using Adobe Air to create a desktop application. In that application I have a tree and i want to add menu to a node when it right clicked. I followed the way they are saying for flex tree, but not working.
Any How-to ?
~Umesh

I am not exactly sure what your problem is, since you don't say whether it did not compile, did not have display or gave a runtime error etc, so I put together a mxml to demonstrate it. The code is mostly cobbled together from the Tree and Menu examples. Please refer to documentation for more details.
<?xml version="1.0" encoding="utf-8"?><mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Menu;
[Bindable]
public var selectedNode:XML;
// Event handler for the Tree control change event.
public function treeChanged(event:Event):void {
selectedNode=mx.controls.Tree(event.target).selectedItem as XML;
}
private var prevMenu:Menu = null
public function showMenu(event:MouseEvent):void
{
if(prevMenu != null)
prevMenu.hide()
var menu:Menu = Menu.createMenu(null, menuData, false);
menu.labelField="#label"
menu.show(event.stageX, event.stageY)
prevMenu = menu
}
]]>
</mx:Script>
<mx:XML id="menuData">
<root>
<menuitem label="copy" eventName="copy"/>
<menuitem label="paste" eventName="paste"/>
</root>
</mx:XML>
<mx:XMLList id="treeData">
<node label="Mail Box">
<node label="Inbox">
<node label="Marketing"/>
<node label="Product Management"/>
<node label="Personal"/>
</node>
<node label="Outbox">
<node label="Professional"/>
<node label="Personal"/>
</node>
<node label="Spam"/>
<node label="Sent"/>
</node>
</mx:XMLList>
<mx:Panel title="Tree Control Example" height="75%" width="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Label width="100%" color="blue"
text="Select a node in the Tree control."/>
<mx:HDividedBox width="100%" height="100%">
<mx:Tree id="myTree" width="50%" height="100%" labelField="#label"
showRoot="false" dataProvider="{treeData}" change="treeChanged(event)"
rightClick="showMenu(event)"/>
<mx:TextArea height="100%" width="50%"
text="Selected Item: {selectedNode.#label}"/>
</mx:HDividedBox>
</mx:Panel></mx:WindowedApplication>

Related

Reusing the same contextMenu xml for ContextMenuMailItem and ContextMenuMultipleItems

When adding items to a context menu (ribbon) in a VSTO outlook add-in (for Outlook 2009+), is there a way to use the same context menu for multiple idMso (i.e., I'd like to add the same items for when single or multiple emails are selected)? I tried the xml below, but the schema doesn't like that I'm re-using the same button id in multiple places.
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<contextMenus>
<contextMenu idMso="ContextMenuMailItem">
<button id="DoThis"
label="Label"
onAction="DoThis"
getVisible="GetVisible"/>
</contextMenu>
<contextMenu idMso="ContextMenuMultipleItems">
<button id="DoThis"
label="Label"
onAction="DoThis"
getVisible="GetVisible"/>
</contextMenu>
</contextMenus>
</customUI>
Ideally I guess I'd like something like this:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<contextMenus>
<contextMenu idMso="ContextMenuMailItem,ContextMenuMultipleItems">
<button id="DoThis"
label="Label"
onAction="DoThis"
getVisible="GetVisible"/>
</contextMenu>
</contextMenus>
</customUI>
Reusing id attribute is not possible, but there is another attribute that is reusable - tag:
<button id="DoThis1" tag="DoThis" ... />
<button id="DoThis2" tag="DoThis" />
Then in the code then you can determine the command not by Id but by Tag property of the control.

Need to parse repeatedly (loop) over the same piece of XML using NSXMLParser

I have a string of XML that I'd like to use to describe a table layout. Sort of like a template. I'm using NSXMLParser to parse this.
<section title="section a">
<row label="name" property="fullname" />
<row label="gender" property="gender" />
</section>
<section title="section b">
<row label="pet" property="pet" />
</section>
<repeat foreach="companies">
<section title="name">
<row label="address" property="address" />
<row label="email" property="email" />
</section>
</repeat>
As for the part between the <repeat> tags, I intent to loop over this part 0 to n times for each of the entries in an array. The NSXMLParser however doesn't seem to have an easy way of doing this. I see no option to jump back to a previous line. The only way I can think of is storing everything between the <repeat> tags in a variable and doing my custom parsing and repeating of it in the parser:didEndElement:... method. I wonder though, isn't there a better way to do this maybe?

Magento2 checkout form: How to display placeholder attribute value in fields?

Goodmorning Stackoverflow,
I'm customizing the checkout onepage in Magento 2. Now I'm trying to display placeholders instead of labels in the shipping-address form, but no success till now. I hope someone can help me out
Cheers, Jorge
UPDATE:
In the console i can see a variable is giving to the attribute placeholder of the element input.
<input class="input-text" type="text" data-bind="
value: value,
valueUpdate: 'keyup',
hasFocus: focused,
attr: {
name: inputName,
placeholder: placeholder, // <<<< right here
'aria-describedby': noticeId,
id: uid,
disabled: disabled
}" name="street[0]" placeholder="" aria-describedby="notice-BVWUCFN" id="BVWUCFN">
Now i would like to know if theres is a way to modify this variable via the backend, so i can display label name in the placeholder attr.
See screenshot
Apoligies for my bad english
Standard way,
Copy all html files from vendor/magento/module-ui/view/frontend/web/templates/form/element/
at
app/design/frontend/<Vendor>/<theme>/Magento_Ui/web/templates/form/element/
Then change all Change placeholder: placeholder to placeholder: label as mention by Akis Verillis.
Now you need to deploy the static files by below code:
php bin/magento setup:static-content:deploy
And see the magic.
Note: If you have checkout from github then try copy from
/app/code/Magento/Ui/view/base/web/templates/form/element/
Change placeholder: placeholder to placeholder: label
The answer is in Magneto 2 documentation now:
http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_edit_form.html
The templates are the ones mentioned in previous answers.
The templates from magento-ui module are used in other places than checkout.
In your custom module directory, create a new /view/frontend/layout/checkout_index_index.xml file. In this file, add content similar to the following:
...
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
...
<item name="shippingAddress" xsi:type="array">
<item name="children" xsi:type="array">
<!-- The name of the form the field belongs to -->
<item name="shipping-address-fieldset" xsi:type="array">
<item name="children" xsi:type="array">
<!-- the field you are customizing -->
<item name="telephone" xsi:type="array">
<item name="config" xsi:type="array">
<!-- Assigning a new template -->
<item name="elementTmpl" xsi:type="string">%Vendor_Module%/form/element/%your_template%</item>
%Vendor_Module%/form/element/%your_template%
path is [your theme dir]/Vendor_Module/web/template/form/element/your_template.html
Clear browser cache too beside:
Delete all files in the pub/static/frontend and var/view_preprocessing directories.
If this is useful for you, the definition of that element is in:
/app/code/Magento/Ui/view/base/web/templates/form/element/input.html
It defines an input as:
<input
class="admin__control-text"
type="text"
data-bind="
value: value,
hasFocus: focused,
attr: {
name: inputName,
placeholder: placeholder,
'aria-describedby': noticeId,
id: uid,
disabled: disabled
}" />
You can add placeholder item to a layout.xml file for your field. Just like this:
<item name="address" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
<item name="config" xsi:type="array">
<item name="customScope" xsi:type="string">contactForm</item>
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/input</item>
</item>
<item name="placeholder" xsi:type="string">Address</item>
<item name="dataScope" xsi:type="string">address</item>
<item name="label" xsi:type="string">Address</item>
<item name="sortOrder" xsi:type="string">20</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="string">true</item>
</item>

variable to custom component - flex

I'm trying to pass a variable from my main flex application to a custom component I've created, but haven't really figured anything out.
my variable is just a string - public var test:String = "a test";
my custom component is implement in my main application like this - <ns1:finaltest includeIn="FinalTest" x="26" y="19" />
In my custom component 'finaltest' I'd like just to display the variable 'test'. something like this - finalmessage.text = test;
MainApp.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" xmlns:local="*"
>
<fx:Script>
<![CDATA[
[Bindable]
public var test:String = "a test";
]]>
</fx:Script>
<local:FinalTest finalMessage="{test}" />
</s:Application>
FinalTest.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="400" height="300"
>
<fx:Script>
<![CDATA[
[Bindable]
public var finalMessage:String;
]]>
</fx:Script>
<s:Label text="{finalMessage}" />
</s:Group>

FlashBuilder 4/Flex, set transparent background for web app?

I'm embeding a flex application into a web page using the most recent version of swfobject.js. I've set wmode to transparent and all that but whatever I've enterd for the embeded objects default size, is then a white background within my application. I've set the application's backgroundAlpha to 0 and I know that part works because my aplication resizes after it has finished loading. The resized portion of the application is transparent but the rest still has the white background so it's obvious it has something to do with the application and not the html or javascript embedding it. How do i fix this?
Looking at the default application skin I noticed that it makes use of the backgroundColor style property to set the fill color for the backgroundRect of the applicaton. However, there's no mention of backgroundAlpha so I created a new application skin and added a single line of code which works!
Below this line:
bgRectFill.color = getStyle('backgroundColor');
Add the following:
bgRectFill.alpha = getStyle('backgroundAlpha');
In your application .mxml file set the skinClass property to:
skinClass="YourSkinsDirectory.YourApplicationSkin"
I have mine saved as ApplicationSkin.mxml in a folder called Skins
so mine looks like this: skinClass="Skins.ApplicationSkin"
Here's the full skin:
<?xml version="1.0" encoding="utf-8"?>
<!--
ADOBE SYSTEMS INCORPORATED
Copyright 2008 Adobe Systems Incorporated
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the license agreement accompanying it.
-->
<!--- The default skin class for the Spark Application component.
#see spark.components.Application
#langversion 3.0
#playerversion Flash 10
#playerversion AIR 1.5
#productversion Flex 4
-->
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009" alpha.disabled="0.5" alpha.disabledWithControlBar="0.5">
<fx:Metadata>
<![CDATA[
/**
* A strongly typed property that references the component to which this skin is applied.
*/
[HostComponent("spark.components.Application")]
]]>
</fx:Metadata>
<fx:Script fb:purpose="styling">
<![CDATA[
/**
* #private
*/
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number) : void
{
bgRectFill.color = getStyle('backgroundColor');
bgRectFill.alpha = getStyle('backgroundAlpha');
super.updateDisplayList(unscaledWidth, unscaledHeight);
}
]]>
</fx:Script>
<s:states>
<s:State name="normal" />
<s:State name="disabled" />
<s:State name="normalWithControlBar" />
<s:State name="disabledWithControlBar" />
</s:states>
<!-- fill -->
<!---
A rectangle with a solid color fill that forms the background of the application.
The color of the fill is set to the Application's backgroundColor property.
-->
<s:Rect id="backgroundRect" left="0" right="0" top="0" bottom="0">
<s:fill>
<!--- #private -->
<s:SolidColor id="bgRectFill" color="#FFFFFF" alpha="1"/>
</s:fill>
</s:Rect>
<s:Group left="0" right="0" top="0" bottom="0">
<s:layout>
<s:VerticalLayout gap="0" horizontalAlign="justify" />
</s:layout>
<!---
#private
Application Control Bar
-->
<s:Group id="topGroup" minWidth="0" minHeight="0"
includeIn="normalWithControlBar, disabledWithControlBar" >
<!-- layer 0: control bar highlight -->
<s:Rect left="0" right="0" top="0" bottom="1" >
<s:stroke>
<s:LinearGradientStroke rotation="90" weight="1">
<s:GradientEntry color="0xFFFFFF" />
<s:GradientEntry color="0xD8D8D8" />
</s:LinearGradientStroke>
</s:stroke>
</s:Rect>
<!-- layer 1: control bar fill -->
<s:Rect left="1" right="1" top="1" bottom="2" >
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xEDEDED" />
<s:GradientEntry color="0xCDCDCD" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<!-- layer 2: control bar divider line -->
<s:Rect left="0" right="0" bottom="0" height="1" alpha="0.55">
<s:fill>
<s:SolidColor color="0x000000" />
</s:fill>
</s:Rect>
<!-- layer 3: control bar -->
<!--- #copy spark.components.Application#controlBarGroup -->
<s:Group id="controlBarGroup" left="0" right="0" top="1" bottom="1" minWidth="0" minHeight="0">
<s:layout>
<s:HorizontalLayout paddingLeft="10" paddingRight="10" paddingTop="7" paddingBottom="7" gap="10" />
</s:layout>
</s:Group>
</s:Group>
<!--- #copy spark.components.SkinnableContainer#contentGroup -->
<s:Group id="contentGroup" width="100%" height="100%" minWidth="0" minHeight="0" />
</s:Group>
</s:Skin>