[Chameleon] button within a widget

Ken-ichi kueda at wso.williams.edu
Fri Nov 5 19:12:33 EST 2004

Thanks for the tips Paul.  I've been working a different project for a 
while, hence the lag.  I've successfully added a button to my widget 
using your instructions and adapting some code from the UpdateMap 
widget, but every time the page loads, I get a javascript error that reads:

image object for cwcimage_16 not found?

I'm fairly sure this is because the button is only drawn when the widget 
is displaying results, which only happens when another widget is used to 
select an area on the map.  So even though the button is not written 
into the HTML, its JavaScript CWCButton object still is.  You can take a 
look at this at http://fisher.cnr.berkeley.edu/vtm/data/mapbrowse/, and 
using the Select VTM Quads tool to select quads on the map.  Whenever 
quad results are not displayed you get the error.

Any ideas on how I can fix this?


PS. My button-related InitDefaults() lines look like this:

//initialize the Add Data button ($moButton)
        $this->moButton->SetOnClick( 'VTMAddData' );

        $this->moButton->mszStyleResource = "TextButtons";
        $this->moButton->moParent->maParams['LABEL'] = "Add Data";
        $oApp = GetChameleonApplication();
        $szImage = $oApp->findFile( 'icons/icon_update.png' );
        $this->moButton->maszImages['normal'] = 
$this->moButton->GetImage( 'normal', array( "image" => $szImage ) );
        $this->moButton->maszImages['hover'] = 
$this->moButton->GetImage( 'hover', array( "image" => $szImage ) );
        $this->moButton->maszImages['selected'] = 
$this->moButton->GetImage( 'selected', array( "image" => $szImage ) );
        $this->moButton->mszImageTip = "Add VTM Data";

Paul Spencer wrote:

> You can easily do this ... the steps are (roughly):
> * include the button code:
> include_once( dirname(__FILE__)."/../Button.php" );
> * add a class member variable to hold the button object:
> class myWidget extends CWCWidget
> {
> var $moButton = null;
> * In the constructor of your widget:
> $this->moButton = new CWCButton( $this );
> * In InitDefaults:
> $this->moButton->InitDefaults();
> $this->moButton->SetOnClick( 'myWidgetFunction' );
> You will need to call all the functions that CWCButton uses, check 
> Button.php to see which ones they are.  In general, it will be
> function GetJavascriptIncludes()
> {
>     $aReturn = $this->moButton->GetJavascriptIncludes();
>     //your includes
>     return $aReturn;
> }
> there are several of these ... you need them ALL even if you don't do 
> anything in the functions other than call the button function and 
> return the resulting array.
> in DrawPublish() you can now do:
> $szButton = $this->moButton->DrawPublish();
> and then incorporate $szButton into your output that gets returned 
> from DrawPublish.
> The button will call myWidgetFunction( ) when clicked.  
> myWidgetFunction will receive the button object as the first 
> parameter, then any other parameters you supplied (see Button.php to 
> pass other parameters, its not usually necessary)
> Cheers,
> Paul
> Ken-ichi wrote:
>> Hi all.  I'm developing a custom and rather non-standard widget that 
>> shows geospatial datasets based on a rectangular query, and then 
>> allows the user to choose which results to add to the map.  It's 
>> non-standard because it shows results in the same window as the map, 
>> as opposed to a popup.  I want to add a submit button to the widget's 
>> output (DrawPublish()) but I'm not sure how to go about embedding a 
>> textbutton within a widget.  I supposed I could just include the 
>> straight HTML for the form input in my widget, but I'd like to just 
>> use a standard Chameleon textbutton if possible.  Is there a way to 
>> do this?
>> Thanks.
>> -Ken-ichi
>> _______________________________________________
>> Chameleon mailing list
>> Chameleon at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/chameleon

More information about the Chameleon mailing list