CTO Blog

September 21 2006

I've seen a couple request from customers wanting the ability to keep some of their users out of certain areas in GiftWorks. Below is a small addin that attempts to solve that problem by removing the toolbar buttons at the top of the window. In this example I remove every application button except the Donors button (see the picture to the right).

See my HelloWorld post and my What's In A GiftWorks Addin post for more details on using the following addin file. This post will skim through the details and assume you've already created and used an addin file. 

   1:  <gml id="MissionResearch_DisableExample">
   2:      <info>
   3:          <title>Disable Addin Example</title>
   4:          <versions>
   5:              <version match="2.0.*.*" module="version2" />
   6:          </versions>
   7:      </info>
   8:      <module id="version2">
   9:          <objects>
  10:              <object id="MyObject" type="vbscript" url="" cache=""><![CDATA[
  11:                  Sub EventHandler(Ev)
  12:                      If Ev.Data.Url = "toolbar" Then
  13:                          For Each button In App.Shell.Toolbar.Buttons
  14:                              If button.Title <> "Donors" Then
  15:                                  App.Shell.Toolbar.Buttons.Remove button.Title
  16:                              End If
  17:                          Next
  18:                      End If
  19:                  End Sub
  20:              ]]></object>
  21:          </objects>
  22:          <handlers>
  23:              <handler id="module-execute" object="MyObject"/>
  24:          </handlers>
  25:      </module>
  26:  </gml>

 

toolbar buttons

The toolbar buttons at the top of GiftWorks are the main navigation elements for the application. GiftWorks inserts several by default and addins can modify those buttons or add their own. This post just concentrates on removing existing buttons. GiftWorks gives you access to these buttons through a Buttons collection.

App.Shell.Toolbar.Buttons

Each button has several properties that you can modify with code.

Button.Order - a number indicating the sort order the buttons should use for display
Button.Action - the action a button executes when clicked
Button.Title - the title of the button displayed
Button.ImageUp - the image file used when the button is in normal state
Button.ImageDown - the image file used when the button is in clicked state
Button.ImageOver - the image file used when the button has a mouse over it
Button.ImageDisabled - the image file used when the button is disabled

event handlers

You can embed event handlers in the addin file to handle events raised by GiftWorks. Event handlers are the primary means for addins to integrate with existing GiftWorks elements. This addin handles a general framework event called 'module-execute' which is fired whenever the framework needs to initialize the toolbar. GiftWorks fills the toolbar first with it's buttons then fires the event so addins can handle it as well. An addin can add toolbar buttons using a simpler interface which will be shown at a later time. This event enables an addin to modify buttons that have already been added. You could rename buttons or other things. This addin just checks for the Donors button and removes everything else. The <handler> element simply tells GiftWorks your addin wants to be called when the 'module-execute' event is raised. It then calls the EventHandler subroutine in the 'MyObject' script.

Try this our and let me know what you think. In later posts I will try to expose some more of the many GiftWorks events.

« GiftWorks and IE7 Compatibilit... | Batch Updates To GiftWorks Don... »
Want More? Try browsing our other Mission Research developer blogs...
Steve Fafel, Mike Greineder, Jonny Leaman

Search


Article Tags


Other Mission Blogs


Past Articles


Ads



Other Links