Class: OpenHAB::DSL::Sitemaps::ButtongridBuilder
- Inherits:
-
LinkableWidgetBuilder
- Object
- WidgetBuilder
- LinkableWidgetBuilder
- OpenHAB::DSL::Sitemaps::ButtongridBuilder
- Defined in:
- lib/openhab/dsl/sitemaps/builder.rb
Overview
Builds a ‘Buttongrid` element
Defined Under Namespace
Modules: Buttongrid
Instance Attribute Summary
Attributes inherited from WidgetBuilder
#icon, #icon_colors, #item, #label, #label_colors, #static_icon, #value_colors, #visibilities
Instance Method Summary collapse
-
#button(row = nil, column = nil, click = nil, label = nil, icon = nil, item: nil, label: nil, icon: nil, static_icon: nil, row: , column: , click: , release: nil, stateless: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil) ⇒ ButtonBuilder
Adds a button inside the buttongrid.
Methods inherited from LinkableWidgetBuilder
#buttongrid, #chart, #colorpicker, #default, #frame, #group, #image, #input, #mapview, #selection, #setpoint, #slider, #switch, #text, #video, #webview
Methods inherited from WidgetBuilder
#icon_color, #label_color, #value_color, #visibility
Methods included from Core::EntityLookup
#items, #method_missing, #things
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OpenHAB::Core::EntityLookup
Instance Method Details
#button(row = nil, column = nil, click = nil, label = nil, icon = nil, item: nil, label: nil, icon: nil, static_icon: nil, row: , column: , click: , release: nil, stateless: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil) ⇒ ButtonBuilder
Adds a button inside the buttongrid
-
In openHAB 4.1, buttons are direct properties of the buttongrid. Only ‘row`, `column`, `click`, `label` (optional), and `icon` (optional) are used. All the other parameters are ignored. All the buttons will send commands to the same item assigned to the buttongrid.
-
In openHAB 4.2+, buttons are widgets within the containing buttongrid, and they support all the parameters listed in the method signature such as ‘release`, `label_color`, `visibility`, etc. Each Button element has an item associated with that button. When an item is not specified for the button, it will default to the containing buttongrid’s item.
This method supports positional arguments and/or keyword arguments. Their use can be mixed, however, the keyword arguments will override the positional arguments when both are specified.
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 |
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 1391 def (row = nil, column = nil, click = nil, label = nil, icon = nil, **kwargs, &block) args = [row, column, click, label, icon].compact args = args.first if args.first.is_a?(Array) kwargs = %i[row column click label icon].zip(args).to_h.compact.merge(kwargs) missing_args = (REQUIRED_BUTTON_ARGS - kwargs.keys).compact unless missing_args.empty? args = kwargs.map { |k, v| "#{k}: #{v.inspect}" }.join(", ") missing_args = missing_args.map(&:to_s).join(", ") raise ArgumentError, "button(#{args}) missing required parameters: #{missing_args}" end kwargs[:item] ||= item if item # default to the buttongrid's item kwargs[:label] ||= kwargs[:click].to_s ButtonBuilder.new(@builder_proxy, **kwargs, &block).tap do |b| children << b end end |