Module: UI::EventDispatcher
- Included in:
- Dialog
- Defined in:
- library/general/src/lib/ui/event_dispatcher.rb
Overview
Provides switch between event_loop and dispatching to handlers. A #handle_event method can be defined to delegate some events.
Instance Method Summary collapse
-
#cancel_handler ⇒ Object
Default handler for cancel which can be also 'x' on dialog window.
-
#event_loop ⇒ Object
Does UI event dispatching.
-
#finish_dialog(return_value = nil) ⇒ Object
Set internal flag to not continue with processing other UI inputs.
-
#user_input ⇒ Object
Reads input for next event dispath Can be redefined to modify the way of getting user input, like introducing a timeout.
Instance Method Details
#cancel_handler ⇒ Object
Default handler for cancel which can be also 'x' on dialog window
104 105 106 |
# File 'library/general/src/lib/ui/event_dispatcher.rb', line 104 def cancel_handler finish_dialog end |
#event_loop ⇒ Object
Does UI event dispatching.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'library/general/src/lib/ui/event_dispatcher.rb', line 39 def event_loop Yast.import "UI" @_finish_dialog_flag = false loop do input = user_input if respond_to?(:"#{input}_handler") public_send(:"#{input}_handler") elsif respond_to?(:handle_event) public_send(:handle_event, input) else raise "Unknown action #{input}" end return @_finish_dialog_value if @_finish_dialog_flag end end |
#finish_dialog(return_value = nil) ⇒ Object
Set internal flag to not continue with processing other UI inputs
98 99 100 101 |
# File 'library/general/src/lib/ui/event_dispatcher.rb', line 98 def finish_dialog(return_value = nil) @_finish_dialog_flag = true @_finish_dialog_value = return_value end |
#user_input ⇒ Object
Reads input for next event dispath Can be redefined to modify the way of getting user input, like introducing a timeout. Default implementation uses Yast::UI.UserInput which waits indefinitely for user input. end
92 93 94 |
# File 'library/general/src/lib/ui/event_dispatcher.rb', line 92 def user_input Yast::UI.UserInput end |