Create New Widget: Difference between revisions

From PSwiki
Jump to navigation Jump to search
Ethryn (talk | contribs)
m add to category (Engine documents)
m Reverted edits by Luca (Talk) to last revision by Ethryn
 
(One intermediate revision by one other user not shown)
(No difference)

Latest revision as of 22:33, 10 December 2010

To create a new widget you simply have to subclass one of the existing widgets ( or the base one ) and implement the functions you want to change. Almost every function in the widget class is a virtual one which allows you to customize the widget the way you want. For example, say you want to create a widget that all it does is play a sound when the mouse is moved over it. For this you can subclass the base widget pawsWidget and just implement the OnMouseEnter() and the OnMouseExit() functions.

 class MyNewWidget : public pawsWidget
 {
 public:
   virtual bool OnMouseEnter()
   {
      MyPlaySound();
   }
   virtual bool OnMouseExit()
   {
     MyStopSound();
   }
 private:
   void MyPlaySound() { ... }
   void MyStopSound() { ... }
 };


Next update will be to show how to create the factory and the XML for this so you can do something like specify a sound to play.