Kbase 21816: An Easy Way to Add a New Button in a SmartToolbar
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/20/2002 |
|
SUMMARY:
This Solution applies to the ADM2 in Progress Version 9.x. It shows you one way to add a new button to a SmartToolbar. This method requires changes only within the SmartContainer where the Toolbar is placed.
EXPLANATION:
A SmartToolbar knows how to deal with 4 Action Groups: TABLEIO, NAVIGATION, TRANSACTION and FUNCTION. Adding the new button in the "FUNCTION" group, which by default has only FILTER action initially disabled, is the easiest approach. This can be done with the "initializeObject" procedure shown below by taking out the code for the "myButtons" group.
SOLUTION:
The code to create the button is placed in initializeObject of the container.
PROCEDURE initializeObject:
/*-----------------------------------------------------------
Purpose: Super Override
Parameters:
Notes:
------------------------------------------------------------*/
/* Code placed here will execute PRIOR to standard behavior. */
DEF VAR xcColumns AS CHARACTER
INITIAL "Name,Caption,Image,Type,OnChoose,AccessType,Parent".
&SCOP dlmt + CHR(1) +
/* only to define a new Action Group */
dynamic-function( "defineAction" IN h_dyntoolbar,
"myButtons":U, /* action group */
"Name,Caption":U,
"myButtons" {&dlmt} /* Name */
"myButtons" {&dlmt} /* Caption */
"":U ).
/* define an action for my button */
DYNAMIC-FUNCTION( "defineAction":U IN h_dyntoolbar,
"myButtonAction":U, /* Action */
xcColumns,
"myButtonAction" {&dlmt} /* Name */
"myButtonAction" {&dlmt} /* Caption*/
"filter.bmp":U {&dlmt} /* Image */
"PUBLISH":U {&dlmt} /* TYPE */
/* when you press the button the smart toolbar */
/* will PUBLISH myButtonAction */
"myButtonAction":U {&dlmt} /* OnChoose */
"READ":U {&dlmt} /* AccessType */
"myButtons":U {&dlmt} /* parent */
/* Parent - change it to FUNCTION if you don't want a new group */
"":U
).
/* enable my action */
DYNAMIC-FUNCTION( 'enableActions' IN h_dyntoolbar,
"myButtonAction" ).
RUN SUPER.
/* Code placed here will execute AFTER standard behavior. */
/* create a button in toolbar for my action */
DYNAMIC-FUNCTION( 'createToolbar':U IN h_dyntoolbar,
"myButtonAction" ).
/* subscribe the container to act at my action */
SUBSCRIBE TO "myButtonAction" IN h_dyntoolbar.
END PROCEDURE.
The container replies to my action with myButtonAction
procedure. If you need to disable/enable the button use
enableActions & disableActions as in the example above.
PROCEDURE myButtonAction:
/*------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
-------------------------------------------------------------*/
MESSAGE "myButtonAction not implemented".
END PROCEDURE.
/* create a new procedure named createObjects */
/* and copy the content of adm-create-objects here.*/
/* Look for the piece of code where dyntoolbar is */
/* created and manually add myButtons to */
/* Action Groups. See example. */
/* You don't need createObjects if you place your */
/* buttons in FUNCTION group. */
PROCEDURE createObjects:
/* notice myButtons action-group in the third INPUT parameter for
construct Object */
.
.
.
RUN constructObject (
INPUT 'test/dyntoolbar.w':U ,
INPUT FRAME fMain:HANDLE ,
INPUT 'FlatButtons?yes?Menu?yes?ShowBorder?yes?Toolbar?yes?ActionGroups?Tableio,Navigation,myButtons?SubModules??TableIOType?Update?SupportedLinks?Navigation-source,Tableio-source?EdgePixels?2?PanelType?Toolbar?NavigationTargetName??HideOnInit?no?DisableOnInit?no?ObjectLayout?':U ,
OUTPUT h_dyntoolbar ).
.
.
.
END PROCEDURE.
NOTE: If you enable FILTER action in your application make sure
you override startFilter in NAVIGATION-TARGET of the toolbar (usually
a SDO).