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, #colortemperaturepicker, #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), andicon
(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.
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 |
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 1436 def button(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 |