limited with Game_Views;
package Widgets.Buttons.Pushes is
-- A Push_Button is a variation of a button that is on when it's being
-- pressed with the mouse or keyboard, and immediately returns to off when
-- the mouse or keyboard is released. It does not stay on until clicked
-- again.
type Push_Button is new Button with private;
type A_Push_Button is access all Push_Button'Class;
-- Creates a new push button within 'view' with id 'id'. 'text' is the
-- button's text and 'icon' is the filename of the icon to use. Both are
-- optional but at least one should be specified or the button will be
-- blank.
function Create_Push_Button( view : not null access Game_Views.Game_View'Class;
id : String;
text : String := "";
icon : String := "" ) return A_Button;
pragma Precondition( id'Length > 0 );
pragma Postcondition( Create_Push_Button'Result /= null );
private
type Push_Button is new Button with null record;
-- If the button is pressed and it loses input focus, it will release.
procedure Handle_Blur( this : access Push_Button );
-- Handles Space, Enter and Keypad-Enter keys to turn the button on.
function Handle_Key_Press( this : access Push_Button;
evt : not null A_Key_Event ) return Boolean;
-- Handles Space, Enter and Keypad-Enter keys to turn the button off.
function Handle_Key_Release( this : access Push_Button;
evt : not null A_Key_Event ) return Boolean;
-- Handles the left mouse button to dispatch a Held action.
procedure Handle_Mouse_Held( this : access Push_Button;
evt : not null A_Mouse_Button_Event );
-- Handles the left mouse button to press the button.
procedure Handle_Mouse_Press( this : access Push_Button;
evt : not null A_Mouse_Button_Event );
-- Handles the left mouse button to release the button. A Click action
-- occurs only if the mouse is released while hovering on the button.
-- Otherwise the click is considered aborted. The state still changes to
-- False and a Release action still occurs.
procedure Handle_Mouse_Release( this : access Push_Button;
evt : not null A_Mouse_Button_Event );
-- Toggles the state of the button and then toggles it back again. (Push
-- buttons don't stay on!) Both Press and Release actions will occur.
procedure Toggle_State( this : access Push_Button );
end Widgets.Buttons.Pushes;