Solved

capture selected value from mouseover

Posted on 2011-03-22
12
302 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
  • 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now