?
Solved

capture selected value from mouseover

Posted on 2011-03-22
12
Medium Priority
?
312 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

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 2000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

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…
Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

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