How Do I Programmatically Dispatch an Itemclick Event in Flex 3?
Hi,
I need some help with programmatically dispatching an itemclick event in Flex 3.
For example, I've got a popupmenubutton as follows:
<mx:PopUpMenuButton
id="myPopUpMenuButton"
label="Neighborhoods"
dataProvider="{myNeighborhoodList}"
itemClick="myPopUpMenuButtonClickHandler(event)"
/>
Let's say that the myNeighborhoodList contains 3 choices: Old Port, Newport, Southport.
In another piece of code, I want to programmatically dispatch the myPopUpMenuButton itemclick event as if "Newport" were chosen. How do I do that?
FYI, I posted this question on Stack Overflow, but I didn't get a reply.
Thank you!
-Laxmidi
Ok , here is how I solve the problem architecturally. One class should be responsible for the viewstack index. This class can respond to events dispatched anywhere. So it goes a little something like this.
The view stack
<Viewstack selctedIndex="{stackIndex}">
<Script>
[Bindable] public var stackIndex:int;
</Script>
<ViewOne />
<ViewTwo/>
<ViewThree />
</Viewstack/>
StackPresentation.as
public var stackCount:int;
[Bindable] public var stackIndex:int;
public function startUp():int
stackIndex = someRandomNumberGenerator( 0 , stackCount );
return stackIndex;
public function changeStackHandler( newStackIndex:int ):void
stackIndex = newStackIndex;
There are a few things I must explain here.
1. The stackIndex of the StackPresentation class in "injected" into the Viewstack class. This can be accomplished using a number of frameworks. Personally I use Mate , but there is a whole cornucopia of DI frameworks ( Prana , RobotLegs , Swiz ...).
2. When you want to change the stack index from any part of the application , you dispatch an event like the one I posted earlier. Your framework will wire this event to the StackPresentation. The event will have some parameters ( i.e var newStackIndex:int ) which it uses to go to the next stack index , it could very well be different from what I posted as this is an example.
The advantages of this are numerous. But they all stem from "separation of concern". The view class is responsible for being a view , and the presentation is responsible for coordinating the state of the view class. The other advantage is that if some other part of the application wants to change the viewstack index , it MUST go through the presentation layer , preventing a "ball of mud" type of approach. This greatly cuts down on the number of bugs and the time it takes to resolve them. In scenarios where there is a problem , you only have to look at a few things , the logic in the presentation class ( which lends itself to unit-testing) and the cases where the event triggering the change is dispatched. Hope this helps.
Sincerely ,
Ubu
Similar Messages
-
Revision: 12818
Revision: 12818
Author: [email protected]
Date: 2009-12-10 16:20:49 -0800 (Thu, 10 Dec 2009)
Log Message:
The MX TabBarAccImpl now sends the MSAA event EVENT_OBJECT_SELECTION followed by EVENT_OBJECT_FOCUS when the TabBar dispatches an "itemClick" event. Previously it only sent EVENT_OBJECT_SELECTION.
QE notes: None
Doc notes: None
Bugs: SDK-17927
Reviewer: Jon, Hans
Tests run: checkintests
Is noteworthy for integration: No
Ticket Links:
http://bugs.adobe.com/jira/browse/SDK-17927
Modified Paths:
flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/TabBarAccImpl.asCan't solve your immediate problem, but thought this might be of interest.
I created a tutorial on converting the Adobe Flex 3 example Dashboard application to Flex 4.
The tutorial is here:
http://stardustsystems.com/learning/flex4/tutorials/portDashboardToFlex4/index.html
There are links to the tutorial PDF, the converted applicaton, and the source code.
Hope this helps someone.
http://www.stardustsystems.com
http://www.stardustsystems.com/blog -
Dispatching an ItemClick event from a chart
I am trying to provide a simple drill down by getting a name
from a pie slice and then putting the slices contents in a datagrid
based on that name as a filter.
I am trying to use an event dispatcher and an event listener,
but im not exactly sure im doing it right.
The dispatcher would dispatch when something is clicked, and
the string item of what is clicked would be passed into the
remote object. (Not sure how the ItemClick string is passed
by an event)
I know i'm a newb with events.... thanks for any input.
here is the chart component
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="
http://www.adobe.com/2006/mxml"
title="Defect Chart (Status not Closed)" layout="absolute"
width="100%" height="100%">
<mx:Script>
<![CDATA[
import mx.charts.ChartItem;
import mx.collections.ArrayCollection;
//Label function for the Defect Pie Chart
private function labels(dataItem:Object, field:String
,Index:int, dataPercent:Number ):String
return dataItem.BG_SEVERITY + " " + dataItem.CNT;
private function ItemClick(name:String):void
dispatchEvent(new ChartItemEvent.);
trace("event is dispatched");
]]>
</mx:Script>
<mx:PieChart id="DefectPie"
width="100%"
height="100%"
showDataTips="true"
y="40"
itemClick="{ItemClick(event.hitData.chartItem.item.toString())}"
>
<mx:series>
<mx:PieSeries id="series"
field="CNT"
nameField="BG_SEVERITY"
labelPosition="callout"
labelFunction="labels"
>
This is called in main's init()
this.addEventListener("name" , ItemClickHandler);
And this is the handler function:
private function ItemClickHandler(event:Event):void
trace(event);
dataManager.soe_bug_list_detail(event['BG_SEVERITY']);
}JoeADSK,
This might sound like a bit over-kill but you might go ahead
and use a seperate EventHandler class and a DTO(Data Transfer
Object) class to accomplish the event even though you are simply
sending 1 piece of data.
Here is an example if you need one:
==Event Handler Class==
package event
import flash.events.Event;
import myApp.dto.ChartItemDTO;
public class ChartClickEvent extends Event
public var chartName:ChartItemDTO;
public function ChartClickEvent(chartName:ChartItemDTO,
type:String)
super(type);
this.chartName = chartName;
override public function clone():Event
return new ChartClickEvent(chartName, type);
DTO Class:
package myApp.dto
public class ChartItemDTO
public var name:String;
public function ChartItemDTO(name:String)
this.name = name;
Here is how you use it in your mxml for or whatever:
import event.ChartClickEvent;
import myApp.dto.ChartItemDTO;
DONT FORGET TO ADD THIS EVENT BLOCK:
<mx:Metadata>
[Event(name="chartName", type="event.ChartClickEvent")]
</mx:Metadata>
HERE IS AN EXAMPLE FUNCTION NON-WORKING===
private function setChartName(name:String):void
var chrtName:ChartItemDTO = new ChartItemDTO(name);
var chrtClickEvent:ChartClickEvent = new
ChartClickEvent(chrtName, "chartName");
dispatchEvent(chrtClickEvent);
Now this is just hacked together quickly not a working model
but you will get the idea.
Basically the event must be passed a Data Transfer Object to
hand off from the Click event.
Like I said this is over-kill but a good place to start as
you venture forth in the the Event Handling world in Flex.
Good luck, hope this helps,
Kenny -
How to cancel datagrid itemclick event for one column with a button control
I have a datagrid that displays rows of data that can be
edited and deleted. To edit the user clicks on a row and the row
data appears above in some text fields and user can edit data then
clicks save and datagrid is refreshed with updated data. Also on
each row is a delete button. This button will delete the current
row of data. The conflict is when user clicks on the delete button
the itemclick event of row is activated and edit fields get filled
and then data row is deleted. I can create some very inefficient
code around this, but i rather not. What I would like to do is
cancel the itemclick event in the delete button column so the
itemclick event never happens when click on the button. Is this
possible?Just ran across this problem myself. My simple approach is to check the columnIndex in the ListEvent that is passed on itemClick.
-
How do I programmat​ically open block diagram?
Hi, All
How do I programmatically open block diagram of subVI and add frame to event structure
Thanks,Could you be a bit more specific on what you are trying to do?
Do you want to programmatically edit an existing VI that is currently not running? As mike said, scripting could work but it is unsupported (see the Lava scripting forum for details: http://forums.lavag.org/LabVIEW-VI-Scripting-f29.html). Somehow, adding an event case does not give you much, you would also need to add the code contents and hook everything up to the existing controls, indicators, and other nodes.
If you just need an event that is not always active during run, maybe you can use user events. Check the online help. (Also have a look at e.g. section 4 in the following application note:
http://zone.ni.com/devzone/cda/tut/p/id/2994.
LabVIEW Champion . Do more with less code and in less time . -
How to disable programmatically an item in a Descriptive flexfield
Hi friends,
doy you know How to disable programmatically an item in a Descriptive flexfield using CUSTOM.pll?
The problem is that I need to do it under the WHEN-NEW-RECORD-INSTANCE event, and the item (based in an attribute column of a database table) hasn't a canvas asociated at that moment....
Do you have any example?
Thanks,
Jose.Hi Prashant,
mmm yes, for now there are two fields it he DFF window.. but in a future .. may be more..
I've found a function:
fnd_flex_key_api.enable_column that may be properly for that, but I don't know what to pass in the the first parameter (flexfield IN flexfield_type)...
I mean: I suppose is the "name" for my DFF but.. how can I get it?
Thanks,
jose. -
Prevent PopUpMenuButton itemClick Event
Hi Guys,
I have a PopUpMenuButton where I would like to prevent the itemClick event from being triggered if the button itself is clicked (not the drop-down with the list of menu items). According to Adobe Live Docs clicking the button fires off the click event, and then also triggers the itemClick event.
How can I prevent the itemClick event from firing?
My reasoning is this: I only want the popupmenubutton to display the dropdown list when the button portion is clicked, not do any other processing. It should behave just as if the drop-down button to the right was clicked, exposing the drop-down list of menu items.
Instead, what happens now if I click the button section is that it shows the drop-down list, but then also fires off the itemClick event, acting as if I selected the first item in the drop-down list (since that is highlighted by default when the list is exposed).
Thanks!That is what I have right now:
<mx:Script>
<![CDATA[
private function toolClickHandler(event:MenuEvent):void
switch(event.label)
case "Password Generator":
var window:PasswordGenerator = PopUpManager.createPopUp(this, PasswordGenerator, true) as PasswordGenerator;
PopUpManager.centerPopUp(window);
break;
]]>
</mx:Script>
<mx:XMLList
id="xl_tool_menu">
<node
label="Tools"
/>
<node
label="Calculator"
/>
</mx:XMLList>
<mx:PopUpMenuButton
id="pmb_tools"
label="Tools"
labelField="@label"
dataProvider="{xl_tool_menu}"
click="this.pmb_tools.open();"
itemClick="toolClickHandler(event);"
/>
However, since Password Generator is the only item in the list, it appears to handle it as always selected, meaning that event.label will always result in "Calculator". -
Is there a way to dispatch or bubble events between two pop-up windows?
Hi. I was wondering if there is a way to dispatch custom
events between two or more pop-up windows created using the
PopUpManager?
I understand how to pass an event from one pop-up window to
the main application (or FrontController) by dispatching the event
from Application.application under Cairngorm 2.0.
However, as I understand it, that will only bubble the event
through the Application chain of visual controls and not to the
other pop-up windows created using the PopUpManager.
I tried dispatching the event directly from the pop-up window
itself, but the other pop-ups still does not seem to receive the
event.
It would be nice to be able to do this so that each non-modal
pop-up can have some awareness with each other.
Thank you very much in advance.If you have just 2 pop-ups you can have them each do a
addEventListener on the other, listening for the event (custom or
otherwise).
If you have an unpredicatable number, then you devise
something else. Suppose you have 3 pop-ups, p1, p2, and p3. Let's
say you also have 1 custom event, E1. Any of those pop-ups is
capable of dispatching an E1 event and you want all of them to
receive it.
Create a class that extends EventDispatcher and instantiate
an object of that class. Each pop-up "registers" with that class,
something like:
controller.addEventListener( "E1", handler ); where handler
is a function in the pop-up.
When a pop-up wants to dispatch an E1 event, it does it
through the controller: controller.dispatchEvent( new E1(data) );
This will automatically dispatch that event to all the
pop-ups, including the one that dispatched the event. So a pop-up
will have to examine the event to see if it sent it and perhaps
ignore it. -
How do I move clips from one Event to another?
How do I move clips from one Event to another?
As soon as I got the new iMovie, I started importing clips and making video's. Unfortunately, I hadn't fully understood the Events feature, so all of my clips are in a single "New Event" Event. I have now created several other Events and named them properly and would like to sort all of my clips into their proper "Event" folders. How do you do that?Ahh, Ok. I actually had to go to Lynda.com to watch a training video of this highly bassackwards maneuver, but now I have it. In other words, while the intuitive thing is to make a new event to hold the clip you want and then open the old event and drag the clip into it's new event, the only way to accomplish this maneuver is to NOT create a new event, but rather, go to the clip AFTER the one you want to move, select it and then Right-Click on it and select SPLIT EVENT BEFORE SELECTED CLIP (or go to FILE>SPLIT EVENT BEFORE SELECTED CLIP). Then you wait a few seconds while the program thinks a bit (no feedback it is doing this - just a pause) and then it automatically creates a new event with the clip you wanted. Now just double-click the new event and name it something meaningful.
Thanks for your help! -
How can I export a list of events for one of many calendars - e.g. "sailing" to use in Excel?
See this thread here
Display number of emails by sender -
How do I programmatically reference the current page in 902?
Hello,
How do I programmatically reference the current page in 902?
The Portal Smart Text option for Current Page is not flexible enough, and I wish to create my own custom greeting using PL/SQL.
Cheers,
Johnhi,
If you are developing a PLSQL Portlet, then you do have a way for getting the page URL.
The page URL can be obtained from the record, portlet_runtime_record. There is a filed page_urlavailable with portlet_runtime_record.
The portlet_runtime_record is passed as a argument to the show_portlet procedure.
--Sriram -
How can I add a birthday calendar event?
How can I add a birthday calendar event?
Also open the calendar app, tap on calendars bottom middle of the screen and make sure under other you have birthdays ticked in the calendars
-
How do you change the color of events on ICal.
How do you changed the color of events on ICal? I was able to do this when I utilized ICal on the Snow Leopard system but can no longer do this with Lion.
I know that I can select the Calanders list, but when I create a new "Calander" it doesn't allow me to choose a color and it doesn't show up in my list when working within an event.
Thanks!Phoebe,
Right-click on the new calendar and select "Get Info."
Make sure that the ✓ mark is selected.
Then choose the color from this pane: -
How can I remove default alarm for events in iCal on devices ios?
Whenever I add an event to my iCal calendar in Mounain Lion it will automatically add one default alert only on my iphone and ipad. These default alarms are not displayed on my macbook or icloud.com
Default alarms are disabled in macbook, icloud.com, and my ios devices.
How can I remove default alarm for events in iCal on devices ios?
Thanks and sorry for my english.
MacBook Pro, Mac OS X 10.8OK, so I have had this issue for the past several months. I think it all started when I upgraded to ML from SL and migrated my calendars and contacts to iCloud. That was a couple months ago. But now I am running 10.8.2, and about two weeks ago I upgraded my iOS devices to 6.0.1.
I don't seem to be having any issues with events that I create now, but all those old events that were migrated to iCloud a couple months ago, many of those sound alerts on the iOS devices even though there was no alert defined when the event was originally created. I have always had alerts off by default both in iCal and on the iOS devices.
So here's the question: is there a way to go through and disable all these spurious event alerts? I've been disabling them as the event reminders come up, but it's irritating. It would be nice if there was a way to turn them off all in one shot somehow. -
After importing clips to Final Cut, they do not show up in the events library. Events from 2014 show up, but not 2015.They show up in the timeline of my project, though. How can I see them in the events browser?
TThose aren't bins. Those are just groupings based on when the content was created or any other selected parameter. Use the action popup in the toolbar tho change the setting.
Maybe you are looking for
-
Lightroom Installation Failed on Windows 8.1
While installing Lightroom cc on my windows 8.1, I met this message. Photoshop and illustrator have been installed successfully. Exit Code: 7 Please see specific errors below for troubleshooting. For example, ERROR: -------------------------------
-
please help me i've tried using the control panel and repairing iTunes but it hasn't worked still getting the same results just in case it helps the control panel says that the version i have currently installed is 11.1.4.62
-
I have 100s of photos in my Photo app on my iPhone. I need to erase them . How?
I don't know how I got all my artwork on to my iPhone, but it takes up too much space. These are not in my camera app, but seperate in Photos. Can I erase them? Message was edited by: Jean Hanamoto
-
I've done some searches but, if they exist, I missed the answers to these questions: . Is it possible to randomize/shuffle the contents of a playlist in the playlist window? 2. If I export a playlist to my Zeno Nano Plus, will it automatically export
-
Failed to exec runform f60webm [error 2] while running form server
Hi, I have just installed oracle9iAS with oracle 8.1.6 on same RH7.1 m/c During installation I got 2 error of makefile of ins_ctx.mk but after installation every thing started except form server when I run form server it gives error:- failed to exec