1. limited with Game_Views; 
  2.  
  3. package Widgets.Buttons.Pushes is 
  4.  
  5.     -- A Push_Button is a variation of a button that is on when it's being 
  6.     -- pressed with the mouse or keyboard, and immediately returns to off when 
  7.     -- the mouse or keyboard is released. It does not stay on until clicked 
  8.     -- again. 
  9.     type Push_Button is new Button with private; 
  10.     type A_Push_Button is access all Push_Button'Class; 
  11.  
  12.     -- Creates a new push button within 'view' with id 'id'. 'text' is the 
  13.     -- button's text and 'icon' is the filename of the icon to use. Both are 
  14.     -- optional but at least one should be specified or the button will be 
  15.     -- blank. 
  16.     function Create_Push_Button( view : not null access Game_Views.Game_View'Class; 
  17.                                  id   : String; 
  18.                                  text : String := ""; 
  19.                                  icon : String := "" ) return A_Button; 
  20.     pragma Precondition( id'Length > 0 ); 
  21.     pragma Postcondition( Create_Push_Button'Result /= null ); 
  22.  
  23. private 
  24.  
  25.     type Push_Button is new Button with null record; 
  26.  
  27.     -- If the button is pressed and it loses input focus, it will release. 
  28.     procedure Handle_Blur( this : access Push_Button ); 
  29.  
  30.     -- Handles Space, Enter and Keypad-Enter keys to turn the button on. 
  31.     function Handle_Key_Press( this : access Push_Button; 
  32.                                evt  : not null A_Key_Event ) return Boolean; 
  33.  
  34.     -- Handles Space, Enter and Keypad-Enter keys to turn the button off. 
  35.     function Handle_Key_Release( this : access Push_Button; 
  36.                                  evt  : not null A_Key_Event ) return Boolean; 
  37.  
  38.     -- Handles the left mouse button to dispatch a Held action. 
  39.     procedure Handle_Mouse_Held( this : access Push_Button; 
  40.                                  evt  : not null A_Mouse_Button_Event ); 
  41.  
  42.     -- Handles the left mouse button to press the button. 
  43.     procedure Handle_Mouse_Press( this : access Push_Button; 
  44.                                   evt  : not null A_Mouse_Button_Event ); 
  45.  
  46.     -- Handles the left mouse button to release the button. A Click action 
  47.     -- occurs only if the mouse is released while hovering on the button. 
  48.     -- Otherwise the click is considered aborted. The state still changes to 
  49.     -- False and a Release action still occurs. 
  50.     procedure Handle_Mouse_Release( this : access Push_Button; 
  51.                                     evt  : not null A_Mouse_Button_Event ); 
  52.  
  53.     -- Toggles the state of the button and then toggles it back again. (Push 
  54.     -- buttons don't stay on!) Both Press and Release actions will occur. 
  55.     procedure Toggle_State( this : access Push_Button ); 
  56.  
  57. end Widgets.Buttons.Pushes;