The only way I have seen this possible is to use the PopUpManager.
For our app, a user can delete a participant from their group (by
dragging their ADG row to a trash can), but have to provide a reason
why. So, we created a TitleWindow component that we pull in via the
PopUpManager. Here's the code. I imagine there is a better way to do
this, but this is what works for us.
The component (called DeleteParticipantTitleWindow.mxml):
<?xml version="1.0"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
showCloseButton="true"
width="350" height="100%"
borderAlpha="1"
verticalAlign="middle" horizontalAlign="center">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
]]>
</mx:Script>
<mx:Text text="Please enter a reason for removing this participant:"/>
<mx:TextInput id="reason" width="300"/>
<mx:HBox>
<mx:Button id="okButton" label="OK"/>
<mx:Button id="cancelButton" label="Cancel"/>
</mx:HBox>
</mx:TitleWindow>
Then we reference it in our code like this:
First, we alert them (using our custom alert which extends the standard
alert class) that their delete is permanent:
private function deleteParticipantDrop(event:DragEvent):void
{
var component:IUIComponent =
IUIComponent(event.currentTarget);
dragComponent = component;
DragManager.acceptDragDrop(component);
isEditingParticipantInfo = false;
isDeletingParticipant = true;
deleteParticipantDropEvent = event;
event.stopImmediatePropagation();
alert.confirm("Are you sure you want to delete this
participant from the project? This cannot be reversed!! An email will
be " +
"sent to notify this participant and you will
receive a copy of it for your records.", confirmRemoveParticipant);
}
Then, on confirmation, we popup a window where they have to provide the
reason for delete (the key here is the deleteReason = ... in the third
line of the conditional):
private function confirmRemoveParticipant(event:CloseEvent):void
{
if (event.detail == Alert.YES)
{
deleteParticipantDropEvent.action =
DragEvent.DRAG_COMPLETE;
dispatchEvent(deleteParticipantDropEvent);
deleteReason =
DeleteParticipantTitleWindow(PopUpManager.createPopUp( this,
DeleteParticipantTitleWindow , true));
PopUpManager.centerPopUp(deleteReason);
deleteReason.showCloseButton = true;
deleteReason.title = "Reason for removal from project";
deleteReason.addEventListener("close",
cleanupRemoveParticipant);
deleteReason["cancelButton"].addEventListener("click",
cleanupRemoveParticipant);
deleteReason["okButton"].addEventListener("click",
finalizeDeleteParticipant);
isDeletingParticipant = false;
}
else
{
cleanupRemoveParticipant();
}
}
Then, once they enter "ok", we validate their text entry and continue
with the delete, which I've removed all that code for this, but wanted
to show how to access the text field from the popup.
public function finalizeDeleteParticipant(event:Event):void
{
if (deleteReason.reason.text != null)
{
memberReportData.removeItemAt(memberRpt.selectedIndex);
}
else
{
alert.info("You must provide a reason for removing a
participant from your project!!");
}
cleanupRemoveParticipant();
}
Hope this helps!
Adrian
stinasius wrote:
hi how can i add a text/text input, in an alert control in flex?