Solved

capture selected value from mouseover

Posted on 2011-03-22
12
309 Views
Last Modified: 2012-06-27
hi guys


i have a requirment where i have a label . when user puts the cursor on the label
a small window should popup and show the usernames from an ArrayCollection. When a username is clicked the clicked username should be passed to backend.

Here is the mxml

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
      xmlns:projectWork="org.view.projectWork.*"
      xmlns:projectNav="org.view.projectNav.*"
      creationComplete="init()"
      styleName="dashBoardPage"
      xmlns:services="services.*">

<mx:Script >
<![CDATA[
import org.entity.project.ProjectSummaryDTO;
[Bindable]
public var users:ArrayCollection;  --> this collection has a list of usernames
public var selectedusername:String; -->holds the selected username
                  
<mx:Label styleName="usernames" text="show users"/>  --when user puts mouse here, a window should popup and show the usernames from 'users' Arraycollection

<mx:VBOX>

If 5 usernames are displayed in the box , when user clicks on a username i need to capture that username and pass it to the backend.
So i have created a string var 'selectedusername' which will contain the selected username.

Am i in the right direction?
Can anyone please help me with some code

thanks
0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 29

Expert Comment

by:dgofman
ID: 35194434
Why you cannot user component List and show all 5 usernames as dataProvider
when user click on row you will listen itemClick event and set selectedusername - event.target.selectedItem;
0
 

Author Comment

by:royjayd
ID: 35194508
by dataprovider do you mean datagrid? I dont want to use a datagrid. My boss wants a pop-up window when the mouse cursor is placed on the label. Is that possible?

thanks
0
 
LVL 29

Expert Comment

by:dgofman
ID: 35194528
Everything is possible just need to know what you want

<mx:Script>
            <![CDATA[
                  import mx.controls.Alert;
            ]]>
      </mx:Script>
      <mx:Label styleName="usernames" text="show users" mouseOver="Alert.show(event.target.text)"/>

0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:royjayd
ID: 35194717
Ok cool.. When I click on a username I need to pass the username to my
java backend. Any idea how I can do that?

Thanks for the help
0
 
LVL 29

Expert Comment

by:dgofman
ID: 35194725
what services are you using? RemoteObject, WebService or HttpService?
0
 

Author Comment

by:royjayd
ID: 35194913
using RemoteObject to call java methods. So i am basically passing the selected username
to the backend java method.

thx
0
 
LVL 29

Accepted Solution

by:
dgofman earned 500 total points
ID: 35195006
<mx: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">
      
      <fx:Script>
            <![CDATA[
                  import mx.containers.TitleWindow;
                  import mx.controls.Alert;
                  import mx.controls.List;
                  import mx.events.ListEvent;
                  import mx.managers.PopUpManager;

                  [Bindable]
                  private var selectedUser:String;
                  [Bindable]
                  private var users:Array = ["User1", "User2", "User3"];
                  
                  private function selectUser(event:Event):void{
                        var popup:TitleWindow =  PopUpManager.createPopUp(this, TitleWindow, true) as TitleWindow;
                        popup.title = "Select User";
                        popup.width = 300;
                        popup.height = 200;
                        PopUpManager.centerPopUp(popup);
                        var list:List = new List();
                        list.percentWidth = 100;
                        list.percentHeight = 100;
                        list.dataProvider = users;
                        popup.addChild(list);
                        list.addEventListener(ListEvent.ITEM_CLICK, itemClickHandler);
                  }

                  protected function itemClickHandler(event:ListEvent):void
                  {
                        selectedUser = event.itemRenderer.data as String;
                        PopUpManager.removePopUp(event.target.parent);
                        ro.UpdateUser.send();
                  }

            ]]>
      </fx:Script>
      <fx:Declarations>
            <mx:RemoteObject id="ro" destination="MyRemoteObjectDest"
                                     fault="Alert.show(event.fault.faultString), 'Error'">
                  <mx:method name="UpdateUser">
                        <mx:arguments>
                              <user>{selectedUser}</user>
                        </mx:arguments>
                  </mx:method>
            </mx:RemoteObject>
      </fx:Declarations>
      <mx:Label text="Current Selected User is '{selectedUser}'" click="selectUser(event)"/>
</mx:Application>

0
 

Author Comment

by:royjayd
ID: 35195023
cool, thx very much

>><mx:Label text="Current Selected User is '{selectedUser}'" click="selectUser(event)"/>
Instead of click, i should be able to do 'mouseover' ,right ?

0
 
LVL 29

Expert Comment

by:dgofman
ID: 35195028
you can assign any events for Label component. (focus, mouseOver, mouseDown, click etc..)
0
 

Author Comment

by:royjayd
ID: 35207240
thanks.

trying to impliment this , have a question

You have      

    <mx:arguments>
    <user>{selectedUser}</user>
    </mx:arguments>
i understand the arguments tag, but can you tell me what is <user> tag? Is this a tag in Flex?

thanks.
0
 
LVL 29

Expert Comment

by:dgofman
ID: 35207634
0
 

Author Comment

by:royjayd
ID: 35233648
thx v much, it works perfectly.

can you please help out with the next question
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Flex/Q_26916522.html

thx.
0

Featured Post

Surfing Is Meant To Be Done Outdoors

Featuring its rugged IP67 compliant exterior and delivering broad, fast, and reliable Wi-Fi coverage, the AP322 is the ideal solution for the outdoors. Manage this AP with either a Firebox as a gateway controller, or with the Wi-Fi Cloud for an expanded set of management features

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Enabling the Skype for Business Meeting Scheduler in Hybrid OWA
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question