Module: TT::GUI::ContainerElement Abstract

Included in:
Container, Window
Defined in:
TT_Lib2/gui.rb

Overview

This module is abstract.

Container and Window implements this.

Since:

  • 2.4.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#controlsObject (readonly)

Since:

  • 2.4.0



387
388
389
# File 'TT_Lib2/gui.rb', line 387

def controls
  @controls
end

Instance Method Details

#add_control(control) ⇒ Boolean

Returns True if the webdialog was open and the control added.

Parameters:

Returns:

  • (Boolean)

    True if the webdialog was open and the control added.

Raises:

  • (ArgumentError)

Since:

  • 2.4.0



399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'TT_Lib2/gui.rb', line 399

def add_control( control )
  raise( ArgumentError, 'Expected Control' ) unless control.is_a?( Control )
  # 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.add_control_to_webdialog( control )
    return true
  end
  false
end

#get_control_by_name(name) ⇒ Control, Nil Also known as: []

Parameters:

  • name (Symbol)

Returns:

Since:

  • 2.5.0



465
466
467
468
469
470
471
472
473
474
# File 'TT_Lib2/gui.rb', line 465

def get_control_by_name( name )
  for control in @controls
    return control if control.name == name
    if control.is_a?( ContainerElement )
      result = control.get_control_by_name( name )
      return result if result
    end
  end
  nil
end

#get_control_by_ui_id(ui_id) ⇒ Control, Nil

Parameters:

  • ui_id (String)

Returns:

Since:

  • 2.5.0



450
451
452
453
454
455
456
457
458
459
# File 'TT_Lib2/gui.rb', line 450

def get_control_by_ui_id( ui_id )
  for control in @controls
    return control if control.ui_id == ui_id
    if control.is_a?( ContainerElement )
      result = control.get_control_by_ui_id( ui_id )
      return result if result
    end
  end
  nil
end

#initialize(*args) ⇒ Object

Since:

  • 2.4.0



390
391
392
393
# File 'TT_Lib2/gui.rb', line 390

def initialize( *args )
  super( *args )
  @controls = []
end

#release!Nil

Returns:

  • (Nil)

See Also:

Since:

  • 2.6.0



480
481
482
483
484
485
486
# File 'TT_Lib2/gui.rb', line 480

def release!
  for control in @controls
    control.release!
  end
  @controls.clear
  super
end

#remove_control(control) ⇒ Boolean

Returns True if the webdialog was open and the control removed.

Parameters:

Returns:

  • (Boolean)

    True if the webdialog was open and the control removed.

Raises:

  • (ArgumentError)

Since:

  • 2.9.0



417
418
419
420
421
422
423
424
425
426
427
428
# File 'TT_Lib2/gui.rb', line 417

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.call_script( 'UI.remove_control', control_ui_id )
    return true
  end
  false
end