Title: Message
I tried this out from sample code given in Flex book - Developing rich clients with Macromedia Flex. It does have the createDelegate method.
 
-Shweta
 
 
-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Abdul Qabiz
Sent: Friday, October 21, 2005 3:12 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Right click and popup window

There is no createDelegate method, it is Delegate.create(...)
 
-abdul


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Parekh, Shweta - BLS CTR
Sent: Friday, October 21, 2005 11:01 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Right click and popup window

Hi,
I tried using the Delegate class for the popup but it still does not work. It gives me an error saying the property being referenced does not have the static attribute. (error on the lines where I use createDelegate method) I'm working on Flex 1.5
 
Any ideas??
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application initialize="myContextMenu()" backgroundColor="#FFFFFF" xmlns:mx="
http://www.macromedia.com/2003/mxml">   
 
<mx:Script>      
import mx.controls.Alert;
import mx.containers.TitleWindow;
import mx.managers.PopUpManager;
     
public var mnuContext:ContextMenu = null;      
 
public function contextItemPressed( obj, item ):Void
{               
  if( item.caption == "Yahoo" )
  {               
   obj.txtReport.text = obj.txtReport.text + "\nYahoo fired.";  
 trace("i am here");
 //var popupWindow:TitleWindow = TitleWindow(PopUpManager.createPopUp(this, FormulaPopup, true));   
 //popupWindow.centerPopUp(this); 
 showFormWin();     
  }
  else if( item.caption == "Google" )
  {               
  obj.txtReport.text = obj.txtReport.text + "\nGoogle fired.";         
  }
  else if( item.caption == "CNet News" )
  {               
  obj.txtReport.text = obj.txtReport.text + "\nCNet News fired.";           
  }     
 }       
    
public function setupContext( Void ):Void
{          
  mnuContext = new ContextMenu();                   
  mnuContext.hideBuiltInItems();
 
  var contextDelegate = mx.utils.Delegate.createDelegate(this, contextItemPressed);
          
  mnuContext.customItems.push( new ContextMenuItem( "Yahoo", contextDelegate ) );           
  mnuContext.customItems.push( new ContextMenuItem( "Google", contextDelegate ) );           
  mnuContext.customItems.push( new ContextMenuItem( "CNet News", contextDelegate ) );           
        
  this["menu"] = mnuContext;           
  txtReport.text = "Setup.";       
}   
 
public function myContextMenu()
{
parent.addEventListener("initialize",mx.utils.Delegate.createDelegate(this, setupContext));
}
 
function showFormWin()

 mx.controls.Alert.show("showFormWin fired.");
 var popupWindow:TitleWindow = TitleWindow(PopUpManager.createPopUp(this, FormulaPopup, true));   
 popupWindow.centerPopUp(this);
}
</mx:Script>   
   
  <mx:TextArea id="txtReport" preferredWidth="175" height="200"/>
</mx:Application>

 Thanks,
Shweta
-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tracy Spratt
Sent: Thursday, October 20, 2005 1:00 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Right click and popup window

Beware of scope issues.

 

Not sure exactly how in your specific case, but you should probably use a Delegate.  I suspect that handleContext is running in a scope that is unaware of showFormWin.

 

Tracy

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Parekh, Shweta - BLS CTR
Sent: Wednesday, October 19, 2005 5:33 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Right click and popup window

 

Thanks Jester. I understand the getEditingData() method better. I got that to work.

I have a question regarding bringing up a popup window when you right click, and click on a particular menu option. I got the right click and creating custom menu by pushing new items working but when I click on a menu option, I want it to popup a window whereas the app just hangs.

Here is the code:
<mx:Script>      
import mx.controls.Alert;
import mx.containers.TitleWindow;
import mx.managers.PopUpManager;
     
public var mnuContext:ContextMenu = null;      
 
public function handleContext( obj, item ):Void
{               
  if( item.caption == "Yahoo" )
  {               
        obj.txtReport.text = obj.txtReport.text + "\nYahoo fired.";  
        trace("i am here");
        //var popupWindow:TitleWindow = TitleWindow(PopUpManager.createPopUp(this, FormulaPopup, true));                       

        //popupWindow.centerPopUp(this);       
        showFormWin();      -- This method is not called at all, I don't see any trace
  }
  else if( item.caption == "Google" )
  {               
        obj.txtReport.text = obj.txtReport.text + "\nGoogle fired.";         
  }
  else if( item.caption == "CNet News" )
  {               
        obj.txtReport.text = obj.txtReport.text + "\nCNet News fired.";           
  }     
 }       
    
public function setupContext( Void ):Void
{          
  mnuContext = new ContextMenu();                   
  mnuContext.hideBuiltInItems();
          
  mnuContext.customItems.push( new ContextMenuItem( "Yahoo", handleContext ) );           
  mnuContext.customItems.push( new ContextMenuItem( "Google", handleContext ) );           
  mnuContext.customItems.push( new ContextMenuItem( "CNet News", handleContext ) );           
        
  this["menu"] = mnuContext;           
  txtReport.text = "Setup.";       
}   

function showFormWin()
{      
        trace("showFormWin fired.");
        var popupWindow:TitleWindow = TitleWindow(PopUpManager.createPopUp(this, FormulaPopup, true));                 

        popupWindow.centerPopUp(this);
}
</mx:Script>   
   
  <mx:TextArea id="txtReport" preferredWidth="175" height="200"/>
</mx:Application>

Any help / ideas on this will be appreciated.

Thanks,
Shweta





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to