indexing description: "[ Store and manage the keyboard focus. Used by EM_WIDGET_SCENE and EM_COMPONENT_SCENE to set and retreive the keyboard focus. Use EM_SHARED_FOCUS to access the singleton instance. ]" date: "$Date$" revision: "$Revision$" class EM_KEYBOARD_FOCUS feature -- Access current_focus: EM_KEYBOARD_SENSITIVE -- Current keyboard focus default_focus: like current_focus -- Default keyboard focus feature -- Status report has_focus: BOOLEAN is -- Is a focus present? do Result := current_focus /= Void end feature -- Element change set_current_focus (an_object: like current_focus) is -- Set `current_focus' to `an_object'. do if an_object /= current_focus then if current_focus /= Void then current_focus.focus_lost_event.publish ([current_focus]) end if an_object = Void then current_focus := default_focus else current_focus := an_object end if current_focus /= Void then current_focus.focus_received_event.publish ([current_focus]) end end ensure focus_set_to_an_object: an_object /= Void implies current_focus = an_object focus_set_to_default: an_object = Void implies current_focus = default_focus end set_default_focus (an_object: like default_focus) is -- Set `default_focus' to `an_object' do if current_focus = default_focus then current_focus := Void end default_focus := an_object if current_focus = Void then set_current_focus (default_focus) end ensure default_focus_set: default_focus = an_object end feature {EM_COMPONENT_SCENE, EM_COMPONENT} -- Implementation new_focus: like current_focus -- The focus to be set when checking phase is over set_new_focus (an_object: like new_focus) is -- Set `new_focus' to `an_object'. do new_focus := an_object ensure new_focus_set: new_focus = an_object end start_check is -- Start checking for a new keyboard focus. do new_focus := Void end stop_check is -- Stop checking for a new keyboard focus. -- Set the keyboard focus to `new_focus'. do set_current_focus (new_focus) end invariant consistent: has_focus implies current_focus /= Void default_focus_if_no_other: current_focus = Void implies default_focus = Void end