Solved

capture selected value from mouseover

Posted on 2011-03-22
12
311 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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
 

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

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

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…
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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