Module: SKUI::ControlManager Abstract
Overview
This module is abstract.
‘Container` and `Window` implements this.
Instance Attribute Summary collapse
- #controls ⇒ Object readonly
Instance Method Summary collapse
-
#add_control(control) ⇒ Boolean
‘True` if the webdialog was open and the control added.
- #find_control_by_name(name) ⇒ Control, Nil (also: #[])
- #find_control_by_ui_id(ui_id) ⇒ Control, Nil
- #initialize ⇒ Object
- #release ⇒ Nil
-
#remove_control(control) ⇒ Boolean
‘True` if the webdialog was open and the control removed.
Instance Attribute Details
#controls ⇒ Object (readonly)
7 8 9 |
# File 'src/SKUI/control_manager.rb', line 7 def controls @controls end |
Instance Method Details
#add_control(control) ⇒ Boolean
Returns ‘True` if the webdialog was open and the control added.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'src/SKUI/control_manager.rb', line 19 def add_control( control ) unless control.is_a?( Control ) raise( ArgumentError, 'Expected Control' ) end if control.parent raise( ArgumentError, 'Control already has a parent' ) end # Add to Ruby DOM tree @controls << control control.parent = self control.window = self.window # Add to Webdialog if self.window && self.window.visible? self.window.bridge.add_control( control ) if control.is_a?(ControlManager) self.window.bridge.add_container( control ) end return true end false end |
#find_control_by_name(name) ⇒ Control, Nil Also known as: []
61 62 63 64 65 66 67 68 69 70 |
# File 'src/SKUI/control_manager.rb', line 61 def find_control_by_name( name ) for control in @controls return control if control.name == name if control.is_a?( ControlManager ) result = control.find_control_by_name( name ) return result if result end end nil end |
#find_control_by_ui_id(ui_id) ⇒ Control, Nil
45 46 47 48 49 50 51 52 53 54 55 |
# File 'src/SKUI/control_manager.rb', line 45 def find_control_by_ui_id( ui_id ) return self if self.ui_id == ui_id for control in @controls return control if control.ui_id == ui_id if control.is_a?( ControlManager ) result = control.find_control_by_ui_id( ui_id ) return result if result end end nil end |
#initialize ⇒ Object
10 11 12 13 |
# File 'src/SKUI/control_manager.rb', line 10 def initialize super() @controls = [] end |
#release ⇒ Nil
76 77 78 79 80 81 82 |
# File 'src/SKUI/control_manager.rb', line 76 def release for control in @controls remove_control( control ) end @controls.clear super end |
#remove_control(control) ⇒ Boolean
Returns ‘True` if the webdialog was open and the control removed.
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'src/SKUI/control_manager.rb', line 88 def remove_control( control ) raise( ArgumentError, 'Expected Control' ) unless control.is_a?( Control ) raise( IndexError, 'Control not found' ) unless controls.include?( control ) @controls.delete( control ) control_ui_id = control.ui_id control.release if self.window && self.window.visible? self.window.bridge.call( 'UI.remove_control', control_ui_id ) return true end false end |