Class: Glimmer::LibUI::ButtonColumnProxy

Inherits:
ControlProxy show all
Includes:
Column, EnableableColumn
Defined in:
lib/glimmer/libui/button_column_proxy.rb

Overview

Proxy for LibUI button column objects

Follows the Proxy Design Pattern

Constant Summary

Constants inherited from ControlProxy

ControlProxy::BOOLEAN_PROPERTIES, ControlProxy::STRING_PROPERTIES

Instance Attribute Summary

Attributes inherited from ControlProxy

#args, #block, #keyword, #libui, #parent_proxy

Instance Method Summary collapse

Methods included from EnableableColumn

#enabled

Methods included from Column

#column_index, #index, #initialize, #name

Methods inherited from ControlProxy

#append_properties, #append_property, boolean_to_integer, #content, control_proxies, create, #default_destroy, #destroy, #destroy_child, #enabled, exists?, image_proxies, #initialize, integer_to_boolean, #libui_api_keyword, main_window_proxy, menu_proxies, #method_missing, new_control, #post_add_content, #post_initialize_child, #respond_to?, #respond_to_libui?, #send_to_libui, #visible, widget_proxy_class, #window_proxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::LibUI::ControlProxy

Instance Method Details

#can_handle_listener?(listener_name) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/glimmer/libui/button_column_proxy.rb', line 46

def can_handle_listener?(listener_name)
  listener_name == 'on_clicked' || super
end

#handle_listener(listener_name, &listener) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/glimmer/libui/button_column_proxy.rb', line 50

def handle_listener(listener_name, &listener)
  case listener_name
  when 'on_clicked'
    on_clicked(&listener)
  else
    super
  end
end

#notify_listeners(listener_name, *args) ⇒ Object



59
60
61
62
63
# File 'lib/glimmer/libui/button_column_proxy.rb', line 59

def notify_listeners(listener_name, *args)
  @on_clicked_procs&.each do |on_clicked_proc|
    on_clicked_proc.call(*args)
  end
end

#on_clicked(&block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/glimmer/libui/button_column_proxy.rb', line 35

def on_clicked(&block)
  # TODO consider generalizing into custom listeners and moving to ControlProxy
  @on_clicked_procs ||= []
  if block.nil?
    @on_clicked_procs
  else
    @on_clicked_procs << block
    block
  end
end