--
-- Copyright (c) 2012 Kevin Wellwood
-- All rights reserved.
--
-- This source code is distributed under the Modified BSD License. For terms and
-- conditions, see license.txt.
--
-- The Simple_Input_Listener class provides a mechanism for registering any
-- method of a class, matching a certain prototype, as an input action handler.
--
-- Instantiate this package with the class and class-wide access type of an
-- object that will handle input actions.
generic
type Target (<>) is tagged limited private;
package Widgets.Menu_Enumerations.Simple_Listeners is
type A_Handler is access
procedure( object : not null access Target'Class;
action : A_Enum_Action );
-- Invokes the 'handler' method of 'obj' for all input actions.
function Listener( obj : access Target'Class;
handler : not null A_Handler ) return A_Enum_Listener;
pragma Postcondition( Listener'Result /= null );
private
type Simple_Enum_Listener is new Simple_Action_Listener and
Enum_Listener with
record
object : access Target'Class := null;
handler : A_Handler := null;
end record;
-- Invokes the handler procedure of the simple enum listener's target.
procedure Handle_Action( this : access Simple_Enum_Listener;
action : A_Enum_Action );
end Widgets.Menu_Enumerations.Simple_Listeners;